Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Simple userform help

I'm pretty new to Excel, but I have used userforms in
Word before; I think I just need some help getting
started. What I want is to have a userform that will
increase prices in a worksheet by x%. The user will type
in the number on the userform and click submit. Then all
the prices already in columns B and C will increase by
that percent. I know that sounds ridiculously simple, but
I can't even think of how to get the values from the
worksheet and put new values back in.

Should I even bother with a userform? I suppose I could
create a separate worksheet for them to enter in the %
increase, but what if they add or remove items?

Thanks in advance!
Auschten
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Simple userform help

AUschten,

A form does seem overkill, why not just capture cell input.

Anyway, assuming the percentage goes in a textbox, this code will do it

Dim cell As Range

For Each cell In ActiveSheet.Range("B:C")
If Not IsEmpty(cell.Value) Then
If IsNumeric(cell.Value) Then
cell.Value = cell.Value * (1 + TextBox1.Text)
End If
End If
Next cell

--

HTH

RP

"auschten" wrote in message
...
I'm pretty new to Excel, but I have used userforms in
Word before; I think I just need some help getting
started. What I want is to have a userform that will
increase prices in a worksheet by x%. The user will type
in the number on the userform and click submit. Then all
the prices already in columns B and C will increase by
that percent. I know that sounds ridiculously simple, but
I can't even think of how to get the values from the
worksheet and put new values back in.

Should I even bother with a userform? I suppose I could
create a separate worksheet for them to enter in the %
increase, but what if they add or remove items?

Thanks in advance!
Auschten



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Simple userform help

Private Sub CommandButton1_Click()
Dim dblMult As Double
Dim cell As Range, rngB As Range
Dim rngC As Range
If IsNumeric(TextBox1.Value) And _
Len(TextBox1.Value) < 0 Then
dblMult = CDbl(TextBox1.Value)
If dblMult < 0 Then
With Worksheets("Sheet1")
Set rngB = .Range(.Cells(1, "B"), _
.Cells(Rows.Count, "B").End(xlUp))
Set rngC = .Range(.Cells(1, "C"), _
.Cells(Rows.Count, "C").End(xlUp))
End With
For Each cell In rngB
if isnumeric(cell) then
cell.Value = cell.Value * (1 + dblMult)
End if
Next
For Each cell In rngC
if isnumeric(cell) then
cell.Value = cell.Value * (1 + dblMult)
end if
Next
End If
End If ' isnumeric
End Sub

Greater knowledge of your data could significantly reduce the code needed.

--
Regards,
Tom Ogilvy


"auschten" wrote in message
...
I'm pretty new to Excel, but I have used userforms in
Word before; I think I just need some help getting
started. What I want is to have a userform that will
increase prices in a worksheet by x%. The user will type
in the number on the userform and click submit. Then all
the prices already in columns B and C will increase by
that percent. I know that sounds ridiculously simple, but
I can't even think of how to get the values from the
worksheet and put new values back in.

Should I even bother with a userform? I suppose I could
create a separate worksheet for them to enter in the %
increase, but what if they add or remove items?

Thanks in advance!
Auschten



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Simple userform help

For Each cell In ActiveSheet.Range("B:C")

That's kind of cruel, isn't it <g

--
Regards,
Tom Ogilvy


"Bob Phillips" wrote in message
...
AUschten,

A form does seem overkill, why not just capture cell input.

Anyway, assuming the percentage goes in a textbox, this code will do it

Dim cell As Range

For Each cell In ActiveSheet.Range("B:C")
If Not IsEmpty(cell.Value) Then
If IsNumeric(cell.Value) Then
cell.Value = cell.Value * (1 + TextBox1.Text)
End If
End If
Next cell

--

HTH

RP

"auschten" wrote in message
...
I'm pretty new to Excel, but I have used userforms in
Word before; I think I just need some help getting
started. What I want is to have a userform that will
increase prices in a worksheet by x%. The user will type
in the number on the userform and click submit. Then all
the prices already in columns B and C will increase by
that percent. I know that sounds ridiculously simple, but
I can't even think of how to get the values from the
worksheet and put new values back in.

Should I even bother with a userform? I suppose I could
create a separate worksheet for them to enter in the %
increase, but what if they add or remove items?

Thanks in advance!
Auschten





  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Thanks!

Thanks so much, both of you. I think this will be a big
help!

Auschten


-----Original Message-----
I'm pretty new to Excel, but I have used userforms in
Word before; I think I just need some help getting
started. What I want is to have a userform that will
increase prices in a worksheet by x%. The user will type
in the number on the userform and click submit. Then all
the prices already in columns B and C will increase by
that percent. I know that sounds ridiculously simple,

but
I can't even think of how to get the values from the
worksheet and put new values back in.

Should I even bother with a userform? I suppose I could
create a separate worksheet for them to enter in the %
increase, but what if they add or remove items?

Thanks in advance!
Auschten
.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Simple userform help

It actually worked very fast on my machine - not expected<vbg

Bob

"Tom Ogilvy" wrote in message
...
For Each cell In ActiveSheet.Range("B:C")


That's kind of cruel, isn't it <g

--
Regards,
Tom Ogilvy


"Bob Phillips" wrote in message
...
AUschten,

A form does seem overkill, why not just capture cell input.

Anyway, assuming the percentage goes in a textbox, this code will do it

Dim cell As Range

For Each cell In ActiveSheet.Range("B:C")
If Not IsEmpty(cell.Value) Then
If IsNumeric(cell.Value) Then
cell.Value = cell.Value * (1 + TextBox1.Text)
End If
End If
Next cell

--

HTH

RP

"auschten" wrote in message
...
I'm pretty new to Excel, but I have used userforms in
Word before; I think I just need some help getting
started. What I want is to have a userform that will
increase prices in a worksheet by x%. The user will type
in the number on the userform and click submit. Then all
the prices already in columns B and C will increase by
that percent. I know that sounds ridiculously simple, but
I can't even think of how to get the values from the
worksheet and put new values back in.

Should I even bother with a userform? I suppose I could
create a separate worksheet for them to enter in the %
increase, but what if they add or remove items?

Thanks in advance!
Auschten







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
Simple problem, simple formula, no FUNCTION ! Ron@Buy Excel Worksheet Functions 6 September 28th 07 04:51 PM
Simple Simple Excel usage question BookerW Excel Discussion (Misc queries) 1 June 23rd 05 10:06 PM
Make it more simple or intuitive to do simple things Vernie Charts and Charting in Excel 1 March 16th 05 04:01 AM
Linking userform to userform in Excel 2003 missmelis01 Excel Programming 2 August 27th 04 08:07 PM
Simple VBA Code Question (UserForm) abxy[_30_] Excel Programming 7 February 26th 04 07:11 PM


All times are GMT +1. The time now is 09:45 PM.

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

About Us

"It's about Microsoft Excel"