C
Colin Hayes
Hi
My code below uses columns D and then E to allow a number change via a
Popup.
I need to make this more generic if possible , and instead of having
specific columns I'd like it to work on whichever column I select prior
to running the code.
Can anyone help amend the code below to accommodate this?
Grateful for any help. lrow is a variable representing the last cell in
the column.
Columns("D").Select
Selection.Insert Shift:=xlToRight
Range("D2").Select
Dim intNumber As Double
intNumber = InputBox("Vary Number By How Much?", "Variation")
ActiveCell.FormulaR1C1 = "=RC[1]+" & intNumber
Range("D2").Select
Selection.AutoFill Destination:=Range("D2" & lrow),
Type:=xlFillDefault
Range("D2" & lrow).Select
Range("E1").Select
Selection.Cut Destination:=Range("D1")
Range("D1").Select
Selection.Copy
Range("E1").Select
ActiveSheet.Paste
Columns("D").Select
Application.CutCopyMode = False
Selection.Copy
Columns("E:E").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Columns("D").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
My code below uses columns D and then E to allow a number change via a
Popup.
I need to make this more generic if possible , and instead of having
specific columns I'd like it to work on whichever column I select prior
to running the code.
Can anyone help amend the code below to accommodate this?
Grateful for any help. lrow is a variable representing the last cell in
the column.
Columns("D").Select
Selection.Insert Shift:=xlToRight
Range("D2").Select
Dim intNumber As Double
intNumber = InputBox("Vary Number By How Much?", "Variation")
ActiveCell.FormulaR1C1 = "=RC[1]+" & intNumber
Range("D2").Select
Selection.AutoFill Destination:=Range("D2" & lrow),
Type:=xlFillDefault
Range("D2" & lrow).Select
Range("E1").Select
Selection.Cut Destination:=Range("D1")
Range("D1").Select
Selection.Copy
Range("E1").Select
ActiveSheet.Paste
Columns("D").Select
Application.CutCopyMode = False
Selection.Copy
Columns("E:E").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Columns("D").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft