VBA to Import text file

ionelz

Board Regular
Joined
Jan 14, 2018
Messages
248
Office Version
  1. 365
Platform
  1. Windows
Hi,
I would like to be able to import a VERY large text file, more then 50,000 lines
Every line from text file should go in one cell so result should be in one column in excel
Text file looks like :
========================
******textttttttttttttttttttt hhhhhhhhhhh++++++++++++++
klsfkg;ldasg
eiwotqwthwqo

lDL;ahdlad
###########
lasflhaslfhaldgdg
hasdjakshfjkasf35959032463406

What ever I found on net (VBA to import text file) do not work,
Redardless of size, I get error like out of memory
 
My command button is is Sheet1
But import text file I want to go to sheet2
Post #9 works great, but I have changed one line (to sheet2)
VBA Code:
Set sh1 = ThisWorkbook.Sheets(2)

I want this to apply to sheet2
Range("C4:C1000").ClearContents
but since my command button is in sheet1 it clear in sheet1
how to fix this !? how to say that Range("C4:C1000").ClearContents apply to sheet2
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
After this line:
Set sh1 = ThisWorkbook.Sheets(2)

Put this:
sh1.Range("C4:C1000").ClearContents
 
Upvote 0
Solution
Seems like a better answer would be to pull it in using Power Query....
 
Upvote 0

Forum statistics

Threads
1,214,874
Messages
6,122,034
Members
449,061
Latest member
TheRealJoaquin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top