rollnation2
New Member
- Joined
- Mar 18, 2021
- Messages
- 25
- Office Version
- 2016
- Platform
- Windows
Hello,
Reposting an unsolved dilemma.
I am trying to modify a macro which exports a dynamic range to a text file, the range B2:O* where * is the last used cell in column O.
The code below works well but....
*********************************************************
[/CODE]
Reposting an unsolved dilemma.
I am trying to modify a macro which exports a dynamic range to a text file, the range B2:O* where * is the last used cell in column O.
The code below works well but....
- It prints all cells whereas I want to print only Columns B:O
- I want the VBA to name the txt file what is in cell T2 of the sameworksheet.
*********************************************************
VBA Code:
Sub CrText()
Dim c00 As Variant
Dim textFilePath As String
Dim lngCounter As Long
Dim FF As Integer
textFilePath = CStr(VBA.CurDir) & "\mTextFile.txt"
FF = VBA.FreeFile
c00 = Range("A1").CurrentRegion
Open textFilePath For Output As #FF
For lngCounter = LBound(c00, 1) To UBound(c00, 1)
Print #FF, Join(Application.Index(c00, lngCounter, 0), vbTab)
Next
Close #FF
Shell "C:\WINDOWS\notepad.exe " & textFilePath, vbNormalFocus
End Sub
[CODE=vba]