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

Hi All

I have adapted the code below off info gleaned on this forum and it works OK
, however a question was asked of me what would happen if I was on Holiday or
absent through sickness etc - how would we change the values listed below.
Private Sub Add100_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Customers Prices")
Worksheets("Customers Prices").Select
Range("A3").Select
Tb100.Value = Application.CountIf(Range("J3:J600"), "30")
Tb101.Value = Tb100.Value * 30
Tb102.Value = Application.CountIf(Range("J3:J600"), "15")
Tb103.Value = Tb102.Value * 15
Tb106.Value = Application.CountIf(Range("J3:J600"), "13")
Tb107.Value = Tb106.Value * 13
Tb108.Value = Application.CountIf(Range("J3:J600"), "10")
Tb109.Value = Tb108.Value * 10
Tb110.Value = Application.CountIf(Range("J3:J600"), "5")
Tb111.Value = Tb110.Value * 5
Tb112.Value = Application.CountIf(Range("J3:J452"), "CAR*")
Tb114.Value = Application.CountIf(Range("J3:J452"), "FREE*")
Tb104.Value = (Val(Trim(Tb100.Value))) + (Val(Trim(Tb102.Value))) +
(Val(Trim(Tb106.Value))) + (Val(Trim(Tb108.Value))) +
(Val(Trim(Tb110.Value))) + (Val(Trim(Tb112.Value))) + (Val(Trim(Tb114.Value)))
Tb105.Value = (Val(Trim(Tb101.Value))) + (Val(Trim(Tb103.Value))) +
(Val(Trim(Tb107.Value))) + (Val(Trim(Tb109.Value))) + (Val(Trim(Tb111.Value)))
Tb105.Value = FormatCurrency(Tb105.Value, 2)
Tb103.Value = FormatCurrency(Tb103.Value, 2)
Tb101.Value = FormatCurrency(Tb101.Value, 2)
Tb107.Value = FormatCurrency(Tb107.Value, 2)
Tb109.Value = FormatCurrency(Tb109.Value, 2)
Tb111.Value = FormatCurrency(Tb111.Value, 2)
End Sub

Any help or suggestions most helpful??
--
Many thanks

hazel
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Changing Values

By change the values I assume you mean the 30 and the 15 and the... There are
2 ways to go about this and it depends on how likely it is the values will
need to be changed.

If the values are constants that you do not reasonable forsee needing to be
changed then you can make them constants in your program by declaring them as
const(often done in a seperate module or at the top of existing modules).
This puts all of the constants in one easy to get at spot in the unlikely
event that they do need to be changed. This is not something that your end
users can be expected to do but which any programmer with a bit of knowledge
will be able to easily fix. The value of doing this is that you change the
constant in the one spot then evey line of code that requires taht constant
will be instantly updated.

If the values are relatively constant but you do forsee that they will
change in the future then you may want to set up a Variables sheet in you
workbook where you set out all of these values. By giving your end users a
facility to expose this page you allow relatively unsophisticated end user to
change the values. Then in your program you can just reference the values on
that sheet.
--
HTH...

Jim Thomlinson


"Hazel" wrote:

Hi All

I have adapted the code below off info gleaned on this forum and it works OK
, however a question was asked of me what would happen if I was on Holiday or
absent through sickness etc - how would we change the values listed below.
Private Sub Add100_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Customers Prices")
Worksheets("Customers Prices").Select
Range("A3").Select
Tb100.Value = Application.CountIf(Range("J3:J600"), "30")
Tb101.Value = Tb100.Value * 30
Tb102.Value = Application.CountIf(Range("J3:J600"), "15")
Tb103.Value = Tb102.Value * 15
Tb106.Value = Application.CountIf(Range("J3:J600"), "13")
Tb107.Value = Tb106.Value * 13
Tb108.Value = Application.CountIf(Range("J3:J600"), "10")
Tb109.Value = Tb108.Value * 10
Tb110.Value = Application.CountIf(Range("J3:J600"), "5")
Tb111.Value = Tb110.Value * 5
Tb112.Value = Application.CountIf(Range("J3:J452"), "CAR*")
Tb114.Value = Application.CountIf(Range("J3:J452"), "FREE*")
Tb104.Value = (Val(Trim(Tb100.Value))) + (Val(Trim(Tb102.Value))) +
(Val(Trim(Tb106.Value))) + (Val(Trim(Tb108.Value))) +
(Val(Trim(Tb110.Value))) + (Val(Trim(Tb112.Value))) + (Val(Trim(Tb114.Value)))
Tb105.Value = (Val(Trim(Tb101.Value))) + (Val(Trim(Tb103.Value))) +
(Val(Trim(Tb107.Value))) + (Val(Trim(Tb109.Value))) + (Val(Trim(Tb111.Value)))
Tb105.Value = FormatCurrency(Tb105.Value, 2)
Tb103.Value = FormatCurrency(Tb103.Value, 2)
Tb101.Value = FormatCurrency(Tb101.Value, 2)
Tb107.Value = FormatCurrency(Tb107.Value, 2)
Tb109.Value = FormatCurrency(Tb109.Value, 2)
Tb111.Value = FormatCurrency(Tb111.Value, 2)
End Sub

Any help or suggestions most helpful??
--
Many thanks

hazel

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Changing Values

Hi Jim

Thank you for the quick response - It would probably be best to put the
values on a Variables sheet so that I could leave the information within a
folder on the Desk Top -- maybe hide the sheet and perhaps use a combobox
aligned to RowSource they could then update the values if necessary. Would
that be possible and still be able to have the CountIf procedure?
If you could point me in the right direction will have a go at it -- it was
the "30" & "15" etc -- that was the values I was referring to.
--
Many thanks

hazel


"Jim Thomlinson" wrote:

By change the values I assume you mean the 30 and the 15 and the... There are
2 ways to go about this and it depends on how likely it is the values will
need to be changed.

If the values are constants that you do not reasonable forsee needing to be
changed then you can make them constants in your program by declaring them as
const(often done in a seperate module or at the top of existing modules).
This puts all of the constants in one easy to get at spot in the unlikely
event that they do need to be changed. This is not something that your end
users can be expected to do but which any programmer with a bit of knowledge
will be able to easily fix. The value of doing this is that you change the
constant in the one spot then evey line of code that requires taht constant
will be instantly updated.

If the values are relatively constant but you do forsee that they will
change in the future then you may want to set up a Variables sheet in you
workbook where you set out all of these values. By giving your end users a
facility to expose this page you allow relatively unsophisticated end user to
change the values. Then in your program you can just reference the values on
that sheet.
--
HTH...

Jim Thomlinson


"Hazel" wrote:

Hi All

I have adapted the code below off info gleaned on this forum and it works OK
, however a question was asked of me what would happen if I was on Holiday or
absent through sickness etc - how would we change the values listed below.
Private Sub Add100_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Customers Prices")
Worksheets("Customers Prices").Select
Range("A3").Select
Tb100.Value = Application.CountIf(Range("J3:J600"), "30")
Tb101.Value = Tb100.Value * 30
Tb102.Value = Application.CountIf(Range("J3:J600"), "15")
Tb103.Value = Tb102.Value * 15
Tb106.Value = Application.CountIf(Range("J3:J600"), "13")
Tb107.Value = Tb106.Value * 13
Tb108.Value = Application.CountIf(Range("J3:J600"), "10")
Tb109.Value = Tb108.Value * 10
Tb110.Value = Application.CountIf(Range("J3:J600"), "5")
Tb111.Value = Tb110.Value * 5
Tb112.Value = Application.CountIf(Range("J3:J452"), "CAR*")
Tb114.Value = Application.CountIf(Range("J3:J452"), "FREE*")
Tb104.Value = (Val(Trim(Tb100.Value))) + (Val(Trim(Tb102.Value))) +
(Val(Trim(Tb106.Value))) + (Val(Trim(Tb108.Value))) +
(Val(Trim(Tb110.Value))) + (Val(Trim(Tb112.Value))) + (Val(Trim(Tb114.Value)))
Tb105.Value = (Val(Trim(Tb101.Value))) + (Val(Trim(Tb103.Value))) +
(Val(Trim(Tb107.Value))) + (Val(Trim(Tb109.Value))) + (Val(Trim(Tb111.Value)))
Tb105.Value = FormatCurrency(Tb105.Value, 2)
Tb103.Value = FormatCurrency(Tb103.Value, 2)
Tb101.Value = FormatCurrency(Tb101.Value, 2)
Tb107.Value = FormatCurrency(Tb107.Value, 2)
Tb109.Value = FormatCurrency(Tb109.Value, 2)
Tb111.Value = FormatCurrency(Tb111.Value, 2)
End Sub

Any help or suggestions most helpful??
--
Many thanks

hazel

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
Changing values by a % jon Excel Worksheet Functions 4 January 21st 09 03:05 PM
changing values ydkjim Excel Discussion (Misc queries) 2 November 18th 08 12:30 PM
changing values in one column based on values in another? QuickLearner[_18_] Excel Programming 1 July 10th 06 04:18 PM
Changing Cell Values RD Wirr Excel Programming 3 November 15th 05 02:21 AM
Changing values in formulas with VBA mirca_00 Excel Programming 3 June 23rd 04 02:51 AM


All times are GMT +1. The time now is 12:01 AM.

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"