Finding last column

  • Thread starter Thread starter SOS
  • Start date Start date
S

SOS

Hi all,

My question is:


If my range is A1:D6 (but not always)

and the line of code

a = Range("A" & Rows.Count).End(xlUp).Row

returns that I have 6 rows, then why doesn't the line of code:

b = Range("1" & Columns.Count).End(xlToLeft).Column

return that I have 4 columns

Regards

Seamus
 
Because a range is of the form IV1, not 1 256

Try this

b=cells(1,columns.Count).end(xltoleft).column

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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