Forum Discussion
rijuthomas
Jul 22, 2019Copper Contributor
Need help in macros
i have a excel which i have attached to this post, where in raw sheet is the raw data in which i need to insert a column in between A and B and copy the heading of the data against the date, final co...
rijuthomas
Jul 30, 2019Copper Contributor
Kodipadysorry i think wrong file uploaded, have uploaded correct file
let me know any doubts
<Admin Removed File Attachment for Privacy Reasons >>
HansVogelaar
Jul 22, 2025MVP
Here you go:
Sub InsertColumn()
Dim wsh As Worksheet
Dim ref As String
Dim r As Long
Dim m As Long
Dim v As Variant
Application.ScreenUpdating = False
Set wsh = ActiveSheet ' Worksheets("raw sheet")
wsh.Range("B1").EntireColumn.Insert
m = wsh.Range("C" & wsh.Rows.Count).End(xlUp).Row
For r = 3 To m
v = wsh.Range("C" & r).Value
If IsNumeric(v) Or IsDate(v) Then
wsh.Range("B" & r).Value = ref
Else
ref = v
End If
Next r
wsh.UsedRange.EntireColumn.AutoFit
Application.ScreenUpdating = True
End Sub