View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Using a popup to affect a column of numbers

I tested the code and made a couple of changes. mc allows you to specify the
column. This could be done via input box. I used a dim statement for the
number. The first one does a column and the second does a selected range.

Sub increasetothree()
Dim mc As String
Dim i As Long
Dim newnum As Long
mc = "g"
newnum = InputBox("Enter new num")
For i = 2 To Cells(Rows.Count, mc).End(xlUp).Row
If Cells(i, mc) < newnum Then Cells(i, mc) = newnum
Next i
End Sub

Use this
Sub IncreaseSelectinToNumberDesired()
Dim newnum As Long
Dim c As Range
newnum = InputBox("Enter new num")
For Each c In Selection
If c < newnum Then c = newnum
Next c
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Colin Hayes" wrote in message
...
In article , Don Guillett
writes
something like
sub increasetothree()
newnum=inputbox("Enter new num"
for i= 2 to cells(rows.count, "a").end(xlup).row
if cells(i,"a")<newnum then cells(i,"a")=newnum
next i
end sub

HI Don

OK Thanks for that.

No joy I'm afraid. I ran it but it had no effect on the numbers I had
highlighted. It just needs to affect the selection.

I had these numbers highlighted in the column :

3.00
3.50
4.00
4.50
5.00
5.50
6.00
6.50
7.00
7.50
8.00
8.50
9.00
9.50


I ran the macro and entered the number 7 in the popup and clicked OK. No
effect I'm afraid. They just all stayed the same.

I was hoping for this outcome :

7.00
7.00
7.00
7.00
7.00
7.00
7.00
7.00
7.00
7.50
8.00
8.50
9.00
9.50

I did add a closed bracket after "Enter new num" in your code above.


Grateful if you could advise.

Thanks