开发者

selecting all cells in excel sheet from an offset (VBA)

开发者 https://www.devze.com 2023-01-05 23:41 出处:网络
So I am creating an excel report from an access database. So this is done in access VBA. Here is my code:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号