selecting all cells in excel sheet from an offset (VBA)
So I am creating an excel report from an access database. So this is done in access VBA.
Here is my code:
Public Sub ExportActiveSheet()
'irrelevant data
'get the info
ExcelSheet.Range("A3").CopyFromRecordset rs
Set rs = Nothing
End Sub
so now, as you can see.. my recordset gets copied to a range starting from A3. I have an unknown number of columns (right now, user can select between 1 column to 36 columns, but this can grow. Again this should be irrelevant).
I want to select everything from A3 till the end of the worksheet (or, even better only the rows where there is data) and change the row height.
I have tried:
ExcelSheet.Range(Cells(3, 1), Cells(10000, 40)).Select
With ExcelApp.Selection
.RowHeight开发者_开发知识库 = 22.5
End With
but it gives me a Method Range of object _worksheet failed
error
You could always try:
ActiveSheet.Range("A3:A" & ActiveSheet.UsedRange.Rows.Count).Select
With Selection
.RowHeight = 20
End With
With ExcelSheet
.Cells.RowHeight = 22.5
.Cells.Font.name = "Ariel"
.Cells.Font.Size = 8.5
end with
and then i just changed the stuff (titles, headers) to what I wanted. Much easier. I will mark my own answer as the correct one in 2 days
精彩评论