Copying data from excel to notepad

Status
Not open for further replies.

xsdip

New Member
Joined
May 21, 2019
Messages
28
Hi,

I have written below code for extracting data from cells and exporting to notepad. I have around 2 lak rows and 4 columns. So it takes so much of time to get executed.

So is there any easy time saving way, in which we could extract data and export it to textpad

Sub exporting()

Dim wsheet As Variant
Dim filename As String
Dim openfilename As String
Dim Filenum As Integer
Dim shRead As Worksheet
Dim FN As Integer
Dim eventname As String


Set shRead = ThisWorkbook.Worksheets("Sheet2")
eventname = Range("N4")

Dim lastRow As Long, lastCol As Long


' Get the last cell with data in column A
lastRow = shRead.Cells(shRead.Rows.Count, 11).End(xlUp).row

' Get the last cell with data in row 1
lastCol = shRead.Cells(8, shRead.Columns.Count).End(xlToLeft).Column

openfilename = "C:\Users\HP\Desktop\New folder\New folder\"

For i = 11 To lastCol
wsheet = ActiveSheet.Cells(8, i).Value
filename = wsheet
filename = eventname & "_" & filename & ".txt"
filename = openfilename & filename
For j = 9 To lastRow
mystring = mystring & vbNewLine & Cells(j, i)

FN = FreeFile
Open filename For Output As #FN
Print #FN, mystring
Close #FN
Next j
mystring = ""
Next i

End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Duplicate to: Copying Columns to each notepad

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread. If you do not receive a response, you can "bump" it by replying to it yourself, though we advise you to wait 24 hours before doing so, and not to bump a thread more than once a day.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,215,029
Messages
6,122,757
Members
449,094
Latest member
dsharae57

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