Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
ScottM
 
Posts: n/a
Default programatically selecting columns to import text into

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


  #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


  #3   Report Post  
Posted to microsoft.public.excel.misc
ScottM
 
Posts: n/a
Default programatically selecting columns to import text into

Thanks for the feedback.

Scott


"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
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




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
Text import wizard defaults? Bruce Bowler Excel Discussion (Misc queries) 4 April 3rd 23 10:57 AM
Import comma delimited text Lin Excel Discussion (Misc queries) 3 July 28th 06 04:07 PM
Excel Text Import Wizard [email protected] Excel Discussion (Misc queries) 2 September 12th 05 12:00 AM
import data to specific columns marlea Excel Discussion (Misc queries) 1 August 12th 05 02:05 AM
VBA Import of text file & Array parsing of that data Dennis Excel Discussion (Misc queries) 4 November 28th 04 10:20 PM


All times are GMT +1. The time now is 02:44 AM.

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

About Us

"It's about Microsoft Excel"