I am trying to convert a string to an integer and I am getting an error 13 type mismatch. I am getting the error on the lNewColumn = CStr(sCol) line. I am inserting a new column in the spreadsheet. Than I am cutting another column into the newly inserted column. Finally I am trying to delete the original column that was cut from. Currently what is happening is the cutting and pasting is happening but the wrong column is getting deleted. I have tried a couple of different ways but I can't resolve this. any help is appreciated.
Code:
Dim lNewColumn As Long
Dim sNewColumn As String
With Sheets("Data")
If sCol <> "" Then
.Range(sCol & "1").Value = sName
'Insert new Q Column
.Columns(sMoveCol).Insert Shift:=xlToRight
'Cut and paste existing data and move it to Column Q
Stop
lNewColumn = CStr(sCol)
lNewColumn = lNewColumn + 1
sNewColumn = CStr(lNewColumn)
.Columns(sNewColumn).Cut .Columns(sMoveCol)
'Delete Old empty column
.Columns(sCol).EntireColumn.Delete
Else
.Columns(sMoveCol).Insert Shift:=xlToRight
.Range(sMoveCol & "1").Value = sName
End If
End With