473,394 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Writing Values to Cells in Excel

Does anyone have any sample code that invokes automation to write values
from an Access query to a column of cells on an *existing* Excel worksheet,
ie overwrite what's already there? I'm now aware that SP2 disables the
functionality to have a linked table from an Excel worksheet and am trying
to mitigate for this but automation is completely new to me.

Doug Steele's example is excellent but for me as a newbie it doesn't make it
clear how to loop down through a column of cells in Excel.

Many thanks.

Keith.
Apr 6 '06 #1
4 3321
"Keith Wilby" <he**@there.com> wrote in message
news:44********@glkas0286.greenlnk.net...
Does anyone have any sample code that invokes automation to write values
from an Access query to a column of cells on an *existing* Excel
worksheet, ie overwrite what's already there? I'm now aware that SP2
disables the functionality to have a linked table from an Excel worksheet
and am trying to mitigate for this but automation is completely new to me.

Doug Steele's example is excellent but for me as a newbie it doesn't make
it clear how to loop down through a column of cells in Excel.

Many thanks.

Keith.

Doesn't matter, found these:

http://www.mvps.org/access/modules/mdl0035.htm
Apr 6 '06 #2
"Keith Wilby" <he**@there.com> wrote in message
news:44**********@glkas0286.greenlnk.net...

Doesn't matter, found these:

http://www.mvps.org/access/modules/mdl0035.htm

In Sub sCopyRSExample(), how would I adapt the following code to reference,
for example, cells B8 to B330?

With objSht
.Range(.Cells(1, 1), .Cells(conMAX_ROWS, intLastCol)).ClearContents
.Range(.Cells(1, 1), .Cells(1, rs.Fields.Count)).Font.Bold = True
.Range("A2").CopyFromRecordset rs
End With

Many thanks.
Keith.
Apr 6 '06 #3
Change the fourth line to
..Range("B8").CopyFromRecordset rs

If you have 322 rows in your recordset, it will copy down to B330.

Barry

Apr 6 '06 #4
"Barry Gilbert" <bl*******@gmail.com> wrote in message
news:11**********************@t31g2000cwb.googlegr oups.com...
Change the fourth line to
.Range("B8").CopyFromRecordset rs

If you have 322 rows in your recordset, it will copy down to B330.

Barry


So you only need specify a starting point? Good, thanks Barry.

Keith.
Apr 6 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Nevo | last post by:
Can I write to files, say for example, to an excel spreadsheet and have it written in a certain order or in certain cells? Thanks, VAL
6
by: Paul | last post by:
I was wondering if anyone has had an issue where using vba code to read an excel file and import the data into an access table some records are not imported from the excel file. It seems looking at...
11
by: Mr. Smith | last post by:
Hello all, My code can successfully open, write to, format and save several worksheets in a workbook then save it by a given name, close and quit excel. My problem is that if I try and do it...
0
by: vinidimple | last post by:
Hi i have a serious problem while i was working in Excel.I want to fetch columns from an excel worksheet and i need to compare it with an sql querry fields,so i tried to open an excle...
1
by: indrajith_varma1 | last post by:
Hi Can we read from an existing excel file, retrieve the values, take the 1st row, append apostophe to all the values in the first row and write back the appended values to the 1st row of the...
8
by: fahadqureshi | last post by:
Hello, I posted here before asking a question about reading excel. Now that the reading problem is solved i am having trouble on how to write to an excel file. This was my code to read the excel...
1
by: ramya naidu | last post by:
Sketchs.Add(new SKETCH(SketchWorkSheet.Cells.ToString(), SketchWorkSheet.Cells.ToString(), ...
4
by: John Brock | last post by:
I have a .NET application that, among other things, creates Excel workbooks, and I have run into a very strange problem involving formulas on one worksheet that reference values on another...
4
by: keirnus | last post by:
Hello, I've been coding in Access VBA to create an Excel Graph and it was good. Until I got this error: Please check the code below: Private Sub TestGraph3()
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.