Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.
Sub x()
Dim v, i As Long
Dim iFirstColumn As Integer
Dim iSecondColumn As Integer
Dim iDestinationColumn As Integer
iDestinationColumn = 5
iFirstColumn = Val(InputBox("what percentage to use (ex. 35)?", "Pick", 35))
If iFirstColumn = 0 Then
Exit Sub
End If
iSecondColumn = Val(InputBox("What Column is the price in?", "Pick", 4))
If iSecondColumn = 0 Then
Exit Sub
End If
iDestinationColumn = Val(InputBox("Select Destination column to pick?", "Pick", 4))
If iDestinationColumn = 0 Then
Exit Sub
End If
With Range("A1").CurrentRegion
v = .Resize(, .Columns.Count + 1).Value
.ClearContents
End With
For i = LBound(v, 1) + 1 To UBound(v, 1)
If v(i, iSecondColumn) = "" Then
v(i, iDestinationColumn) = "This should be 0"
Else
v(i, iDestinationColumn) = "This should be (column * .35)"
End If
Next i
Range("A1").Resize(UBound(v, 1), UBound(v, 2)) = v
End Sub
Sub Merge()
'
' Merge Macro
'
' Keyboard Shortcut: Ctrl+Shift+L
'
Dim v, i As Long
Dim iFirstColumn As Integer
Dim iSecondColumn As Integer
Dim iDestinationColumn As Integer
iDestinationColumn = 5
iFirstColumn = Val(InputBox("what percentage to use (ex. 35)?", "Pick", 35))
If iFirstColumn = 0 Then
Exit Sub
End If
iSecondColumn = Val(InputBox("What Column is the price in?", "Pick", 3))
If iSecondColumn = 0 Then
Exit Sub
End If
iDestinationColumn = Val(InputBox("Select Destination column to pick?", "Pick", 5))
If iDestinationColumn = 0 Then
Exit Sub
End If
With Range("A1").CurrentRegion
v = .Resize(, .Columns.Count + 1).Value
.ClearContents
End With
For i = LBound(v, 1) + 1 To UBound(v, 1)
If v(i, iSecondColumn) = "" Then
v(i, iDestinationColumn) = 0
Else
v(i, iDestinationColumn) = v(i, iSecondColumn) * iFirstColumn / 100
End If
Next i
Range("A1").Resize(UBound(v, 1), UBound(v, 2)) = v
End Sub
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.