VBA & Macro Problems

Import Text Files into Excel at Cell D1 with VBA

Anum MushtaqAnum Mushtaq Dec 2, 2026 868 views

Question details

The user wants a VBA procedure to place imported text file data in a new Excel worksheet starting at cell D1.

Import Text Files into Excel Starting at Cell D1 with VBA
Product
Microsoft Excel
Device & OS
not provided
Scenario
A VBA macro opens text files and copies their contents into newly created worksheets.
Observed behavior
The copied data starts at A1 instead of the desired destination, D1.
Before you start

Locate the macro that creates the destination worksheet and copies the text file data. Confirm that TextFile refers to the opened text file workbook and NewSheet refers to the new destination worksheet.

Solution 1Recommended

Set the VBA copy destination to cell D1

Use this change when the macro copies data from the opened text file workbook into a newly created worksheet.

1
Open the macro

In Excel, open the workbook containing the macro, then select Developer > Visual Basic and find the procedure that imports the text files.

2
Change the destination

Replace the existing copy statement with: TextFile.Sheets(1).Range("A1").CurrentRegion.Copy Destination:=NewSheet.Range("D1").

3
Run the updated procedure

Save the macro in a macro-enabled workbook, then run it from Developer > Macros. Open the newly created worksheet and check that the copied data starts at D1.

Set the VBA copy destination to cell D1
Check the source range: CurrentRegion copies the contiguous region around A1. If blank rows or columns separate parts of the source data, use an explicit source range that includes all the data you need.
Free Microsoft Office alternative

Work with spreadsheet data in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface for opening and editing Microsoft Excel files. It can help you move between office suites, but it does not fix an Excel VBA macro; macro support and compatibility may vary.

Open and edit spreadsheet data in WPS SpreadsheetsCompatible with Microsoft Excel formats such as XLSX and XLSUse a familiar interface to ease the move from Microsoft OfficeAccess a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does the imported data start at A1?

The macro's copy or import operation is targeting A1, or another default starting cell. In the copy statement, set Destination:=NewSheet.Range("D1") to place the copied range at D1.

Does changing the destination alter the source text file?

No. The Copy statement reads the source range from TextFile.Sheets(1) and places a copy in NewSheet starting at D1; it does not change the source range.

What if CurrentRegion does not copy all the text data?

CurrentRegion stops at blank rows and columns around the region containing A1. Replace Range("A1").CurrentRegion with an explicit source range that covers the required data.

How do I keep the VBA macro when I save the workbook?

Use File > Save As and choose Excel Macro-Enabled Workbook (.xlsm). Saving as an .xlsx file does not retain VBA macros.