ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How Macro Ask for Variable Input? (https://www.excelbanter.com/excel-programming/334889-how-macro-ask-variable-input.html)

Al Franz

How Macro Ask for Variable Input?
 
Have the following macro code I run on a spreadsheet. Would like the macro
to prompt the user for a variable input where I have "<8" below. Can this
be done?

Cells.Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=NOW()-$P1<8"
With Selection.FormatConditions(1).Interior
.ColorIndex = 37
.Pattern = xlSolid
End With



Dave Peterson

How Macro Ask for Variable Input?
 
You've got one reply to your other post.


Al Franz wrote:

Have the following macro code I run on a spreadsheet. Would like the macro
to prompt the user for a variable input where I have "<8" below. Can this
be done?

Cells.Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=NOW()-$P1<8"
With Selection.FormatConditions(1).Interior
.ColorIndex = 37
.Pattern = xlSolid
End With


--

Dave Peterson

Bob Phillips[_7_]

How Macro Ask for Variable Input?
 
Something like

With Cells
.FormatConditions.Delete
ans = Inputbox("Supply limit (1-10)"
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=NOW()-$P1<" & ans
With .FormatConditions(1).Interior
.ColorIndex = 37
.Pattern = xlSolid
End With
End With

--
HTH

Bob Phillips

"Al Franz" wrote in message
...
Have the following macro code I run on a spreadsheet. Would like the

macro
to prompt the user for a variable input where I have "<8" below. Can this
be done?

Cells.Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=NOW()-$P1<8"
With Selection.FormatConditions(1).Interior
.ColorIndex = 37
.Pattern = xlSolid
End With






All times are GMT +1. The time now is 04:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com