Hello, I am trying to edit a open notepad file from VBA. What I need to happen is deleting certain strings of text. "QTY. 1 EACH SIZE: .75 X 1.375" & "Multiline Text" & "Singleline Text" <-- If any of these shows up in the text file I need it gone and replaced with nothing. Any help will be appreciated.
VBA Code:
Private Sub CreateText_Click()
Dim myCell
Dim i As Integer
Dim Str As String
Dim LastRow As Variant
Dim JobNum As String
Dim ClearTxt As String
On Error Resume Next
JobNum = Right([B3], 6) '<----------------------------------- Selects just the number for the job
MkDir "C:\Trotec\Laser Jobs\JobNumbers\" & JobNum '<--------- Creates a folder named with the job number
Range("A1:A150").Select '<--------------------------------------- Specified cells with blanks will be deleted
Selection.SpecialCells(xlCellTypeBlanks).EntireRow.Delete '<----- Deletes rows with condition
'MichaelSerfling
LastRow = Cells(Rows.Count, "A").End(xlUp).Row '<---------------- Sweeps through until Str is seen
ClearTxt = "QTY. 1 EACH SIZE: .75 X 1.375" & "Multiline Text"
Str = "QTY. 1 EACH SIZE: .75 X 1.375" '<------------------------- Specify term
For i = 1 To LastRow Step 1 '<-----------------------------------
If Sheet1.Range("A" & i).Value = Str Then '<------------------ Looks for the phrase set above
Sheet1.Range("A" & i + 7).Resize(LastRow, 4).Copy '<------- Offsets by 7 to avoid certain rows
Shell "notepad.exe", vbNormalFocus '<---------------------- Opens Notepad
SendKeys "^V" '<------------------------------------------- Paste the range
Exit Sub
End If
Next i
End Sub