selecting a row

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have loaded a text file with delimiters in excel.. It consists of three
columns.. i would like to copy only the third column until the last cell that
contains the data.. but my code is not working correctly.. it is selecting
the entire sheet which contains data.. i have used the belw code.. pls advise
me of a better code..

Range("C1").Select
Range("C1", Selection.End(xlDown)).Select

Thanks,
srikanth
 
One way:

Range("C1:C" & Range("C1").End(xlDown).Row).Select

or

Range("C1:C" & Range("C65536").End(xlUp).Row).Select if there are gaps in
Column C

Is your data actually in three columns or is it in column A and just looks
as though it's across A to C?


Regards

Trevor
 
Thanks for your reply..
The data is in separate columns.. A, B and C..
If i execute the below command it gives a n error..

"Select method of Range class failed"

thanks,
srikanth
 
Try this line of code for your selection:

Range("C1:" & Range("C" & Rows.Count).End(xlUp).Address).Select

It does work - I've tested it. It will even work if C is empty - although
all that will be selected is C1.
 
Both suggestions work for me.

If the column is empty, the entire column will be selected.

In fact, your original code worked for me.


Regards

Trevor
 
Hi,

Thanks a lot for your reply..
The code you have provided working fine in another same project, but the
case in what i am doing is, i uploaded a txt file with delimiters.. so after
uploading entire rows and colums containg the data is selected by default..

I beleive there is some problem in code in loading the text file.. but it
works fine.. hereis the code below.. pls update of any changes.. thanks ag
ain.

Workbooks.OpenText FileName:=FileToOpen _
, Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited,
Other:=True, OtherChar:= _
"|"

FileToOpen contains the file name..
thanks,
srikanth
 
Hi,

Thanks a lot for your reply..
The code you have provided working fine in another same project, but the
case in what i am doing is, i uploaded a txt file with delimiters.. so after
uploading entire rows and colums containg the data is selected by default..

I beleive there is some problem in code in loading the text file.. but it
works fine.. hereis the code below.. pls update of any changes.. thanks ag
ain.

Workbooks.OpenText FileName:=FileToOpen _
, Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited,
Other:=True, OtherChar:= _
"|"

FileToOpen contains the file name..
thanks,
srikanth
 

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