View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben
 
Posts: n/a
Default programatically selecting columns to import text into

Scott

Use Offset(rownum, columnnum) to move the activecell.

ActiveCell.Offset(0, 2).Select

Rarely necessary to select anything.

Example........Instead of

Dim actSht As Worksheet
Set actSht = ActiveSheet
Worksheets("Sheet2").Activate
Range("A1:J10").Select
Selection.Copy
actSht.Activate
Range("K43").Select
ActiveSheet.Paste

use

Worksheets("Sheet2").Range("A1:J10").Copy _
Destination:=ActiveSheet.Range("K43")


Gord Dibben Excel MVP

On Thu, 24 Nov 2005 15:19:48 -0500, "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