Hi I am trying to format an excel spread sheet created by my MS access macro. I wanted to select rows with only values in it. So for example I want to select the first row and text wrap it
I thought this logic would work, but gives me error 1004 (Application-defined or Object defined Error)
Dim my_xl_app As Object
Dim my_xl_workbook As Object
Set my_xl_app = CreateObject("Excel.Application")
Set my_xl_workbook = my_xl_app.Workbooks.Open(C:\PATH)
For x = 1 To 23
my_xl_workbook.sheets(x).Range("A1",my_xl_workbook.sheets(x).Range("A1").End(xlToright)).WrapText = True
Next x
my_xl_workbook.Sheets(x).Range("A1", my_xl_workbook.Sheets(x).Range("A1").End(xlToRight)).WrapText = True is what is being highlighted when I press debug
Thanks in advance

Forloop is looping through Worksheetsmy_xl_workbook.sheets(x)so unless you have 23 worksheets it will through an error 1004 because the worksheet you're trying to select doesn't exist. I think from your question you're attempting to loop through the rows on a worksheet.my_xl_workbook.sheets(x).RANGE("A1:AB1").WrapText = Truewhich worked but then I realized that not all my sheets were same length so when I ran my next formatting codemy_xl_workbook.sheets(x).RANGE("A1:AB1").Autofilterit filtered more than I needed on some spreadsheets.