programatically selecting columns

  • Thread starter Thread starter ScottM
  • Start date Start date
S

ScottM

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
 
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.
 
Range("A1").Select
Selection.Offset(0,2).Select

etc.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Thanks for the assistance. My statement

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

works fine.

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

Scott
 
Columns("D:D").Delete

--

HTH

RP
(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