Still stunbling thru code

  • Thread starter Thread starter JMay
  • Start date Start date
J

JMay

Unfortunately, after years of time "pouring thru trying to understand code" I
can't seem to do the simpliest of things. Here's an example...

In a new WB - Sheet1 I enter into each cell B10:F10 x

then I run this code and I get "INVALID QUALIFIER"
with .Count << highlighted WHY???
Seems like cell F10 would get selected, but no,,,,,,,
Damn this stuff!!

Sub test()
ActiveSheet.Cells(10, Columns.Count.End(xlToLeft)).Select
End Sub
 
I think I'd do it this way

Dim aWS as worksheet
set aWS = activesheet

aWS.Cells(10, aws.Columns.Count).End(xlToLeft).Select
 
Hi,

You have a bracket in the wrong place.

ActiveSheet.Cells(10, Columns.Count).End(xlToLeft).Select

Cheers
Andy
 
I'd use a couple of lines to make it easier to understand:

Option Explicit
Sub test()
Dim LastCol As Long
With ActiveSheet
LastCol = .Cells(10, .Columns.Count).End(xlToLeft).Column
.Cells(10, LastCol).Select
End With
End Sub
 
hi
are you trying to select the row b10 to f10?
try this
ActiveSheet.Range("B10", Range("B10").End(xlToRight)).Select

regards
FSt1
 
Barb,
Thanks
I see the most blatant part of my error, that is of not
enclosing my Cells() reference before using the ".end..."

Excel 101 << one of the many days I skipped that class

I changed it to: (without incident - works great!! - Is it necessary
to use the reference to aWS? If so, why?

Sub test()
ActiveSheet.Cells(10, Columns.Count).End(xlToLeft).Select
End Sub


Again thanks
Jim
 
No, was just trying to find and select only cell F10.

Thanks
Thanks for the code I see where your code does select the full range;
Good to know..
Jim
 

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

Back
Top