Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.
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
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
Excel Pivot Chart - Need to show sum of totals | 3 | 17 | |
Dynamic control of Items in an Excel multiListBox | 7 | 25 | |
locking multiple column ranges | 10 | 23 | |
how to import result to CVS from sql server management studio without comma | 2 | 13 |
Join the community of 500,000 technology professionals and ask your questions.