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
Title | # Comments | Views | Activity |
---|---|---|---|
Excel 2013 how to Get the earliest time per day user wise | 6 | 22 | |
Formula to copy cell and its "format" | 3 | 24 | |
How to hault or freeze parent form when a 2d form is open in vb6 | 3 | 11 | |
Changing absolute cell references | 3 | 7 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
10 Experts available now in Live!