Cell Data To Notepad

dudematters21

New Member
Joined
Oct 12, 2024
Messages
10
Office Version
  1. 365
Hello Masters,

May I ask if there's a VBA code for this..
I need to extract all the data in column A to a notepad
However I dont want to include those rows that has "0" on it
Lastly the notepad should open automatically. TIA!

TIA

1729411841772.png
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Try this!

VBA Code:
Sub jec()
 Dim fPath
 fPath = "C:\Temp\blabla.txt"
 Open fPath For Output As #1
 Print #1, Join(Filter(Application.Transpose(Sheets(1).UsedRange.Resize(, 1)), 0, False), vbLf)
 Close #1
 Shell "notepad.exe " & fPath, vbNormalFocus
End Sub
 
Upvote 0
Try this!

VBA Code:
Sub jec()
 Dim fPath
 fPath = "C:\Temp\blabla.txt"
 Open fPath For Output As #1
 Print #1, Join(Filter(Application.Transpose(Sheets(1).UsedRange.Resize(, 1)), 0, False), vbLf)
 Close #1
 Shell "notepad.exe " & fPath, vbNormalFocus
End Sub
hello jec,

thanks!

the filter did remove the rows that has a 0 output, however the spacing did not went well, theyre all lined up in one line..

also the file saves and gets updated, but im getting an error "File not found" evertime..

can we save this instead in the desktop? so that if ever i share the file to others, we dont need to setup the path.. many thanks!
 
Upvote 0
Weird actually, try this

VBA Code:
Sub jec()
 Dim fPath
 fPath = Environ("temp") & "\blabla.txt"
 Open fPath For Output As #1
 Print #1, Join(Filter(Application.Transpose(Sheets(1).UsedRange.Resize(, 1)), 0, False), vbCrLf)
 Close #1
 Shell "notepad.exe " & fPath, vbNormalFocus
End Sub
 
Upvote 0
Solution
Weird actually, try this

VBA Code:
Sub jec()
 Dim fPath
 fPath = Environ("temp") & "\blabla.txt"
 Open fPath For Output As #1
 Print #1, Join(Filter(Application.Transpose(Sheets(1).UsedRange.Resize(, 1)), 0, False), vbCrLf)
 Close #1
 Shell "notepad.exe " & fPath, vbNormalFocus
End Sub
thanks mate, this works!
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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