Turning column count into a Column Letter

G

genmail

I have a macro where I am looking to be able to dynamically select
data based on how many rows and columns are filled in.
I have the count for the number of columns with data, but I need to
know how to turn that count # into a Column letter (like A, B, C) so
that I can then tell the macro the range to select.

How do I do that? I can find lots to tell me how to count columns,
but nothing that tells me how to translate that value into something
useful to me for my macro.
 
R

Rick Rothstein

If you have a count, then just use the Resize property to create the range.
For example...

NumberOfRows = 5
NumberOfColumns = 9
StartAddress = "C3"
Range(StartAddress).Resize(NumberOfRows, NumberOfColumns).Select
 
T

Tom Lavedas

I have a macro where I am looking to be able to dynamically select
data based on how many rows and columns are filled in.
I have the count for the number of columns with data, but I need to
know how to turn that count # into a Column letter (like A, B, C) so
that I can then tell the macro the range to select.

How do I do that?  I can find lots to tell me how to count columns,
but nothing that tells me how to translate that value into something
useful to me for my macro.

function ColLtr(numb)
ColLtr = Chr(numb + 64)
end function
_____________________
Tom Lavedas
 
P

Per Jessen

Hi

If you have a fixed start cell, you can use something like this:

Range("A1").Resize(RowCount,ColumnCount)

or

Range("A1", Cells(RowCount, ColumnCount))

If you do not start from A1 you can use

Range("D5",Range("D5").Offset(RowCount-1,ColumnCount-1))

Hopes this helps.
....
Per
 

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

Top