Select Range of cells

R

Reggie

Hi and TIA! I'm exporting data from MSAcess to Excel. The data is getting
appended to my worksheet from many different sources(queries). The problem
I'm having is that after I transfer the data I want to select ranges of
cells and format them. The data doesn't always end up in the exact same
location every time as the number of records varies. I can run this code
through the first time and everything works fine, however, if I close out of
excel and try to run it again (after all instances of excel are destroyed
etc.) I get the following error:("Error # 1004' Method 'Cells' of
Object_Global' Failed). Here's what I have:

'Send Detail Recordset to Excel
objWS1.Range("A2").CopyFromRecordset rstDetail
Set DailyRange = objWS1.UsedRange
intRowCount = DailyRange.Rows.Count
intRowCount = intRowCount - 2
With objWS1
.Cells.Font.Size = 10
.Range(Cells(intRowCount, 1), Cells(intRowCount, 15)).Merge
End With
Set objWS1 = Nothing
Basically I need to know how to select a range of cells using variables as
the row & column indexes. Is it possible? Any help is appreciated. Thanks
for your time!!
--
Reggie

"Half this game is 90% mental."

----------
 
R

Reggie

Tom, Thanks for the help. Works perfect. It was driving me nuts!!

--
Reggie

"Half this game is 90% mental."

----------
Tom Ogilvy said:
change

.Range(Cells(intRowCount, 1), Cells(intRowCount, 15)).Merge

to


.Range(.Cells(intRowCount, 1), .Cells(intRowCount, 15)).Merge

Put Full Stops/periods in front of each "Cells"

--
Regards,
Tom Ogilvy

Reggie said:
Hi and TIA! I'm exporting data from MSAcess to Excel. The data is getting
appended to my worksheet from many different sources(queries). The problem
I'm having is that after I transfer the data I want to select ranges of
cells and format them. The data doesn't always end up in the exact same
location every time as the number of records varies. I can run this code
through the first time and everything works fine, however, if I close
out
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top