Hello all, I am using Excel 2007
I am trying to learn VBA which I find a challenge but also very interesting at the same time.
the code below keeps buging out on the Text to columns, also if there is a more efficient way to improve this that would be great, open to any help please
Sub UpdateData()
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
With Range("E:E")
Selection.TextToColumns Destination:=Range("E1"), DataType:=xlDelimited
.Value = Evaluate("if(row(" & .Address & "), text(" & .Address & ", ""mmmm""))")
End With
Columns("P:P").TextToColumns Destination:=Range("P1"), DataType:=xlDelimited
Range("AO1").FormulaR1C1 = "Site Name"
Range("AO2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-25],'Site Name'!C[-40]:C[-39],2,FALSE)"
Selection.AutoFill Destination:=Range("AO2:AO" & LR), Type:=xlFillDefault
Columns("AO:AO").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
End Sub
I am trying to learn VBA which I find a challenge but also very interesting at the same time.
the code below keeps buging out on the Text to columns, also if there is a more efficient way to improve this that would be great, open to any help please
Sub UpdateData()
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
With Range("E:E")
Selection.TextToColumns Destination:=Range("E1"), DataType:=xlDelimited
.Value = Evaluate("if(row(" & .Address & "), text(" & .Address & ", ""mmmm""))")
End With
Columns("P:P").TextToColumns Destination:=Range("P1"), DataType:=xlDelimited
Range("AO1").FormulaR1C1 = "Site Name"
Range("AO2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-25],'Site Name'!C[-40]:C[-39],2,FALSE)"
Selection.AutoFill Destination:=Range("AO2:AO" & LR), Type:=xlFillDefault
Columns("AO:AO").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
End Sub