Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 465
Default Using a popup to affect a column of numbers


Hi All

I need to solve a problem , and would grateful if anyone can help.

I need to input a number via a popup. Then increase all numbers in a
column to the number entered in the popup. The numbers to apply the code
to would already be selected in the wb.

For example , if I entered the number 3 in the popup , all numbers equal
to or below 3 would be increased to 3. All those above would stay the
same.

Example :

Before :

1
2
3
4
5
6

After

3
3
3
4
5
6


Can someone help with some code?

Grateful or any assistance.
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 465
Default Using a popup to affect a column of numbers

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

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
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


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 465
Default Using a popup to affect a column of numbers

In article , Don Guillett
writes
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


Hi Don

OK that's got it - it worked perfectly first time.

Thanks.

Best Wishes
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automating change via popup to a column of numbers Colin Hayes Excel Worksheet Functions 0 May 28th 09 02:59 PM
How does 1 value affect the average? Bruce Excel Worksheet Functions 3 October 26th 07 08:40 PM
How do business loans affect the p & l? Dvcdale Excel Discussion (Misc queries) 4 October 23rd 07 01:55 PM
How do i make a change in one worksheet affect the others elleblaze Excel Worksheet Functions 1 March 21st 06 10:00 PM
Does font affect indent spacing? Ramani Kotaru Excel Worksheet Functions 0 January 26th 05 03:31 AM


All times are GMT +1. The time now is 11:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"