A Quickie

G

gradientS

I have ...

Dim c As String
Dim r As Integer

How do I set ...

c = Current Active Column
r = Current Active Row

... so that no matter where the active cell is on the worksheet, these
values will be returned. Is there such a thing a
WorksheetFunction.CountA for Rows and Columns?
 
R

Robin Hammond

Probably better off using numeric values for both, then using Cells(x,y) to
refer to a particular cell.

e.g.
Dim nCol as integer
Dim lRow as long
nCol = activecell.column
lRow = activecell.row

msgbox "There are " & activesheet.UsedRange.Rows.Count & " used rows"

Robin Hammond
www.enhanceddatasystems.com
 
G

gradientS

thank you... just curious... why column as integer and row as long if A
is column and 1 is row as in A1?
 
H

Harald Staff

Don't use Integer, use Long. See
http://msdn.microsoft.com/library/d...-us/modcore/html/decontheintegerdatatypes.asp

quote:
"Traditionally, VBA programmers have used integers to hold small numbers,
because they required less memory. In recent versions, however, VBA converts
all integer values to type Long, even if they are declared as type Integer.
Therefore, there is no longer a performance advantage to using Integer
variables; in fact, Long variables might be slightly faster because VBA does
not have to convert them."

HTH. Best wishes Harald
 
Top