Dim your vars properly and use application.inputbox for more options.
'using column numbers
Private Sub CommandButton3_Click()
Dim rownum as long, startcol as long, endcol as long, holder As variant
rownum = application.InputBox("Enter the row that swapping process going to happen", type:=1)
startcol = application.InputBox("Enter the column number of the cell you want to swap", type:=1)
endcol = application.InputBox("Enter the column numbedr of the cell that you wanted swap with", type:=1)
holder = Cells(rownum, startcol).Value
Cells(rownum, startcol).Value = Cells(rownum, endcol).Value
Cells(rownum, endcol).Value = holder
End Sub
'using column letters
Private Sub CommandButton3_Click()
Dim rownum as long, startcol as string, endcol as string, holder As variant
rownum = application.InputBox("Enter the row that swapping process going to happen", type:=1)
startcol = application.InputBox("Enter the column letter of the cell you want to swap", type:=2)
endcol = application.InputBox("Enter the column letter of the cell that you wanted swap with", type:=2)
holder = Cells(rownum, startcol).Value
Cells(rownum, startcol).Value = Cells(rownum, endcol).Value
Cells(rownum, endcol).Value = holder
End Sub
The type:=1 tells application.inputbox to expect a number; type:=2 tells application.inputbox to expect a string.
holderis set as an Integer, everything else is a Variant. Second, you probably don't wantrownumto be an integer as you could easily hit the limit on it in a big spreadsheet.Worksheets("Sheet1").Cells(...Dimthe variables correctly, I'm guessing the problem isrownumetc get populated withStringinstead. Fix the variables and the rest will be OK