I have an Excel file from a third party that I wrote a macro to manipulate.
The macro needs to grab a technician's name and insert it prior to each service listed in the row per client.
The excel file is set up as follows.
|RowID|ClientID|CLname|CFname|TLname|TFname|Location|date|Serv|ServDur|ServID|Cost|
Each row has 1 unique client, multiple technicians, each technician can have multiple services.
My macro runs with no errors, yet it makes no changes.
Sub UpdateText()
' UpdateText Macro
' Keyboard Shortcut: Ctrl+Shift+D
Dim fName As String
Dim lName As String
Dim LastRow As Long
Dim LastCell As Long
Dim i As Long
Dim x As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To LastRow
LastCell = Range("IV1").End(xlToLeft).Column
For x = 1 To LastCell
If ActiveCell = "Location" Then
lName = ActiveCell.Offset(0, -2).Value
fName = ActiveCell.Offset(0, -1).Value
ElseIf ActiveCell.Value Like "HC:H*" Then
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveCell.Value = lName
ActiveCell.Offset(0, 1).Value = fName
ActiveCell.Offset(0, 3).Select
End If
Next x
Next i
End Sub
The active cell doesn't move along with the For statement. Meaning the Active Cell is always A1.