Still stunbling thru code

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
 
B

Barb Reinhardt

I think I'd do it this way

Dim aWS as worksheet
set aWS = activesheet

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

Andy Pope

Hi,

You have a bracket in the wrong place.

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

Cheers
Andy
 
D

Dave Peterson

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
 
F

FSt1

hi
are you trying to select the row b10 to f10?
try this
ActiveSheet.Range("B10", Range("B10").End(xlToRight)).Select

regards
FSt1
 
J

JMay

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
 
J

JMay

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
 
Top