ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting a Value into a Range (https://www.excelbanter.com/excel-programming/354975-inserting-value-into-range.html)

Andy

Inserting a Value into a Range
 
I wrote the following code and i cant get the end result in the cell G37 & G38.

So if you anyone can see what i did wrong it would be really great.

Andy

Private Sub Tax()
Dim StateTax As Range
Dim CountyTax As Range
Dim VM As Range
Dim OP As Range
Dim VC As Variant
Dim VS As Variant
Dim OC As Variant
Dim OS As Variant
Dim TST As Variant
Dim TCT As Variant


Set StateTax = Worksheets("BID RECAP SUMMARY").Range("E37")
Set CoutyTax = Worksheets("BID RECAP SUMMARY").Range("E38")
Set VM = Worksheets("BID RECAP SUMMARY").Range("I18")
Set OP = Worksheets("BID RECAP SUMMARY").Range("I33")

Select Case CheckBox40.Value
Case Is = True
VS = StateTax * VM
VC = CountyTax * VM
Case Is = False
VS = 0
VC = 0
End Select

Select Case CheckBox38.Value
Case Is = True
OS = StateTax * OP
OC = CountyTax * OP
Case Is = False
OS = 0
OC = 0
End Select

TST = VS + OS
TCT = VC + OC

Worksheets("BID RECAP SUMMARY").Range("g37").Value = TST
Worksheets("BID RECAP SUMMARY").Range("g38").Value = TCT

END SUB

Jim F

Inserting a Value into a Range
 
you could try:

Worksheets("BID RECAP SUMMARY").Range("g37").FormulaR1C1 = TST
Worksheets("BID RECAP SUMMARY").Range("g38").FormulaR1C1 = TCT

"Andy" wrote:

I wrote the following code and i cant get the end result in the cell G37 & G38.

So if you anyone can see what i did wrong it would be really great.

Andy

Private Sub Tax()
Dim StateTax As Range
Dim CountyTax As Range
Dim VM As Range
Dim OP As Range
Dim VC As Variant
Dim VS As Variant
Dim OC As Variant
Dim OS As Variant
Dim TST As Variant
Dim TCT As Variant


Set StateTax = Worksheets("BID RECAP SUMMARY").Range("E37")
Set CoutyTax = Worksheets("BID RECAP SUMMARY").Range("E38")
Set VM = Worksheets("BID RECAP SUMMARY").Range("I18")
Set OP = Worksheets("BID RECAP SUMMARY").Range("I33")

Select Case CheckBox40.Value
Case Is = True
VS = StateTax * VM
VC = CountyTax * VM
Case Is = False
VS = 0
VC = 0
End Select

Select Case CheckBox38.Value
Case Is = True
OS = StateTax * OP
OC = CountyTax * OP
Case Is = False
OS = 0
OC = 0
End Select

TST = VS + OS
TCT = VC + OC

Worksheets("BID RECAP SUMMARY").Range("g37").Value = TST
Worksheets("BID RECAP SUMMARY").Range("g38").Value = TCT

END SUB


Ken Johnson

Inserting a Value into a Range
 
Hi Andy,
Do you use Option Explicit with your code modules?
Is the code you have posted a copy/paste of the original code or have
you entered it via the keyboard?
You have "Dim CountyTax As Range" and "Set CoutyTax = ....."
Option Explicit would pick up this typo when you run the code.
I can't be certain, but that could be the problem.
Ken Johnson


Andy

Inserting a Value into a Range
 
I inserted the "option explicit"

now it brings up that the checkbox40 has not been defined. So i am confused,
how do i define the value of a checkbox as a variable?

"Ken Johnson" wrote:

Hi Andy,
Do you use Option Explicit with your code modules?
Is the code you have posted a copy/paste of the original code or have
you entered it via the keyboard?
You have "Dim CountyTax As Range" and "Set CoutyTax = ....."
Option Explicit would pick up this typo when you run the code.
I can't be certain, but that could be the problem.
Ken Johnson




All times are GMT +1. The time now is 07:36 PM.

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