Hello,
I have this code which does various things on a worksheet but the issue I'm having is with the last three lines:
Code
With Sheets(Branch_Name)
LastRow = .Cells(Rows.Count, 1).End(xlUp).Row
.Range("A:B").EntireColumn.Insert
.Range("A7:A" & LastRow).Value = "=$C7&$D7&ROUND($S7,5)"
.Range("B7:B" & LastRow).Value = "=$D7&$E7&ROUND($X7,5)"
.Range("V7:V" & LastRow).Value = "=IFERROR(IF(VLOOKUP($A7,'[" & FileName & "]" & .Name & "'!$A:$AB,22,0)="""","""",VLOOKUP($A7,'[" & FileName & "]" & .Name & "'!$A:$AB,22,0)),"""")"
.Columns("V").EntireColumn.HorizontalAlignment = xlCenter
.Range("W7:W" & LastRow).Value = "=IFERROR(IF(VLOOKUP($A7,'[" & FileName & "]" & .Name & "'!$A:$AB,23,0)="""","""",VLOOKUP($A7,'[" & FileName & "]" & .Name & "'!$A:$AB,23,0)),"""")"
.Range("AA7:AA" & LastRow).Value = "=IFERROR(IF(VLOOKUP($A7,'[" & FileName & "]" & .Name & "'!$A:$AB,27,0)="""","""",VLOOKUP($A7,'[" & FileName & "]" & .Name & "'!$A:$AB,27,0)),"""")"
.Columns("AA").EntireColumn.HorizontalAlignment = xlCenter
.Range("AB7:AB" & LastRow).Value = "=IFERROR(IF(VLOOKUP($A7,'[" & FileName & "]" & .Name & "'!$A:$AB,28,0)="""","""",VLOOKUP($A7,'[" & FileName & "]" & .Name & "'!$A:$AB,28,0)),"""")"
.Columns("A:AB").Copy
.Columns("A:AB").PasteSpecial Paste:=xlPasteValues
.Columns("A:B").EntireColumn.Hidden = True
Logo.Copy
.Paste Destination:=Sheets(Branch_Name).Range("C1")
.Cells("C6").Select
End With
Display More
The issue is that once the macro has finished, the logo image that was copied over remains selected which looks untidy so I wanted to unselect it by moving to a different cell which is the purpose of the last line. The problem is that no matter what I try (.Range("C6").Select, Cells("C6").Select, Cells(6, 3).Select etc.) all return the same error 'Select method of Range class failed'
Application.CutCopyMode = False also has no effect.
What am I doing wrong?
Thanks
This has also been posted here: