ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   programatically selecting columns (https://www.excelbanter.com/excel-programming/346539-programatically-selecting-columns.html)

ScottM

programatically selecting columns
 
Hi,

I am writing a macro to import multiple text files into a spreadsheet. The
only part I haven't figured out is how to step sideways, i.e the first text
file should use A1 as its origin, the second file C1, the third E1 and so
on.

Range(A1).Select
Range(C1).Select
Range(E1).Select


/Scott



Andyroo

programatically selecting columns
 
I think you can do this using the offset property. Eg Range("A1").Offset(0,
2) will take you to Range("C1"). The first argument in the bracket is for
rows and the second columns, and you can use negatives to 'move backwards'.
I'm very new to VBA so apologies if I am missing your point.

"ScottM" wrote:

Hi,

I am writing a macro to import multiple text files into a spreadsheet. The
only part I haven't figured out is how to step sideways, i.e the first text
file should use A1 as its origin, the second file C1, the third E1 and so
on.

Range(A1).Select
Range(C1).Select
Range(E1).Select


/Scott




ScottM

programatically selecting columns
 
Sounds interesting Andy. I will try it. Thanks.

Scott


"AndyRoo" wrote in message
...
I think you can do this using the offset property. Eg
Range("A1").Offset(0,
2) will take you to Range("C1"). The first argument in the bracket is for
rows and the second columns, and you can use negatives to 'move
backwards'.
I'm very new to VBA so apologies if I am missing your point.

"ScottM" wrote:

Hi,

I am writing a macro to import multiple text files into a spreadsheet.
The
only part I haven't figured out is how to step sideways, i.e the first
text
file should use A1 as its origin, the second file C1, the third E1 and so
on.

Range(A1).Select
Range(C1).Select
Range(E1).Select


/Scott






Bob Phillips[_6_]

programatically selecting columns
 


--

HTH

RP
(remove nothere from the email address if mailing direct)


"ScottM" wrote in message
...
Hi,

I am writing a macro to import multiple text files into a spreadsheet. The
only part I haven't figured out is how to step sideways, i.e the first

text
file should use A1 as its origin, the second file C1, the third E1 and so
on.

Range(A1).Select
Range(C1).Select
Range(E1).Select


/Scott





Bob Phillips[_6_]

programatically selecting columns
 
Range("A1").Select
Selection.Offset(0,2).Select

etc.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"ScottM" wrote in message
...
Hi,

I am writing a macro to import multiple text files into a spreadsheet. The
only part I haven't figured out is how to step sideways, i.e the first

text
file should use A1 as its origin, the second file C1, the third E1 and so
on.

Range(A1).Select
Range(C1).Select
Range(E1).Select


/Scott





ScottM

programatically selecting columns
 
Thanks for the assistance. My statement

With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & sDir + "\" &
sFileName, Destination:=Range("A1").Offset(0, iPosition))

works fine.

Scott


"Bob Phillips" wrote in message
...
Range("A1").Select
Selection.Offset(0,2).Select

etc.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"ScottM" wrote in message
...
Hi,

I am writing a macro to import multiple text files into a spreadsheet.
The
only part I haven't figured out is how to step sideways, i.e the first

text
file should use A1 as its origin, the second file C1, the third E1 and so
on.

Range(A1).Select
Range(C1).Select
Range(E1).Select


/Scott







ScottM

programatically selecting columns
 
I import two columns of data and want to delete one of them using my macro.
What is the proper syntax?

Scott



Bob Phillips[_6_]

programatically selecting columns
 
Columns("D:D").Delete

--

HTH

RP
(remove nothere from the email address if mailing direct)


"ScottM" wrote in message
...
I import two columns of data and want to delete one of them using my

macro.
What is the proper syntax?

Scott






All times are GMT +1. The time now is 05:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com