Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Inserting a range of cells | Excel Worksheet Functions | |||
Inserting Excel Range into Word | Excel Programming | |||
Inserting data within a named range..HELP | Excel Programming | |||
VBA: copying and inserting a dynamic range | Excel Programming | |||
Inserting value at end of range | Excel Programming |