#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 39
Default selecting a row

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
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,089
Default selecting a row

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


"srikanth" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 39
Default selecting a row

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


"Trevor Shuttleworth" wrote:

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


"srikanth" wrote in message
...
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




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,365
Default selecting a row

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.

"srikanth" wrote:

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


"Trevor Shuttleworth" wrote:

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


"srikanth" wrote in message
...
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




  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,089
Default selecting a row

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


"srikanth" wrote in message
...
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


"Trevor Shuttleworth" wrote:

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


"srikanth" wrote in message
...
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








  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 39
Default selecting a row

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
"JLatham" wrote:

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.

"srikanth" wrote:

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


"Trevor Shuttleworth" wrote:

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


"srikanth" wrote in message
...
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



  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 39
Default selecting a row

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




"Trevor Shuttleworth" wrote:

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


"srikanth" wrote in message
...
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


"Trevor Shuttleworth" wrote:

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


"srikanth" wrote in message
...
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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA - Selecting a Row Elise148 Excel Discussion (Misc queries) 5 June 12th 07 05:29 PM
selecting cells without certain value OTS Excel Worksheet Functions 3 October 11th 06 08:02 PM
Selecting Cells zephyr Excel Discussion (Misc queries) 0 September 12th 06 03:18 PM
Selecting Cells BiggyTwo Excel Worksheet Functions 1 May 19th 06 08:54 PM
Selecting every odd row instauratio Excel Discussion (Misc queries) 2 June 15th 05 09:27 PM


All times are GMT +1. The time now is 07:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"