columns("a")

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
Why the code below is giving me an error message. Complaining about Columns("a")? while second line is fine with using Rows(1).

I check the link below and the author used Columns("C") no probelm.
https://bettersolutions.com/excel/rows-columns/vba-code.htm

Thank you so much

Code:
Sub myrange_3()
    'access rows and cols
    Workbooks(1).activesheets.Columns("A").Value = 2
    Workbooks(1).activesheets.Rows(1).Value = 1
End Sub
 
I don't think that is the problem.
"activesheets" is not valid. There is no "s" on the end (it is not plural).
 
Upvote 0
Check if you have more open books, Then any of the others can be the workbook(1)

144cbf66900df98bd7d289aa81ea8770.jpg


Or try:

Code:
Sub myrange_3()
    'access rows and cols
    [COLOR=#ff0000]ActiveSheet[/COLOR].Columns("A").Value = 2
    [COLOR=#ff0000]ActiveSheet[/COLOR].Rows(1).Value = 1
End Sub
 
Upvote 0
Thank you all. I was focusing on Rows and Columns. Thanks a lot once again
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top