Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VBA - Selecting a Row | Excel Discussion (Misc queries) | |||
selecting cells without certain value | Excel Worksheet Functions | |||
Selecting Cells | Excel Discussion (Misc queries) | |||
Selecting Cells | Excel Worksheet Functions | |||
Selecting every odd row | Excel Discussion (Misc queries) |