M
Maria
Hello - I am new to programming in VB - I am using Excel 2003. I am mostly
reading some Excel help books and Searching on the internet for example code.
Characteristics of userform:
- I have a UserForm that displays properly when excuting the Macro in the
Workbook (which only has 1 worksheet)
- I have only 2 Option Buttons set in a Frame -- the values CAN be selected
(one at a time) -- Option Button Names: OpBtnIVA, OpBtnIVAExento
- I have an OK button - which is NOT working properly - I get an error of
"1004" when clicked -- Button Name: ButtonOK
- I also have code for the UserForm Cancel Control - which IS working
properly.
Results Expected:
1. When selecting OpBtnIVA then Cell D41 will be populated with D39*0.16
(computed value)
Note: D41 is a combined range of cells (D41, D42, E41 and E42) but when
selecting the range (in Excel) the cell is listed as D41.
2. When selecting OpBtnIVAExento then Cell D41 will be populated with the
text EXENTO
Note: D39 is a combined range of cells (D39, D40, E39 and E40) but when
selecting the range (in Excel) the cell is listed as D39
I have tried the following 2 codes in my button but either code is not
functioning.
1st Button Code:
Private Sub ButtonOK_Click()
Dim x As Control
For Each x In Frame1.Controls
If x.Value = "OpBtnIVA" Then
Range(“D41â€).Value = Range("D39") * 0.16
Unload FormIVA
ElseIf x.Value = "OpBtnIVAExento" Then
Range(“D41â€).Value = "EXENTO"
Unload FormIVA
End If
Next
End Sub
2nd Button Code:
Private Sub ButtonOK_Click()
If OpBtnIVA Then Cells(41, D).Value = Cells(39, D).Value * 0.16
If OpBtnIVAExento Then Cells(41, D).Value = "EXENTO"
Unload FormIVA
End Sub
If you need anything else, please indicate. All help is greatly appreciated.
thank you in advance
Maria
reading some Excel help books and Searching on the internet for example code.
Characteristics of userform:
- I have a UserForm that displays properly when excuting the Macro in the
Workbook (which only has 1 worksheet)
- I have only 2 Option Buttons set in a Frame -- the values CAN be selected
(one at a time) -- Option Button Names: OpBtnIVA, OpBtnIVAExento
- I have an OK button - which is NOT working properly - I get an error of
"1004" when clicked -- Button Name: ButtonOK
- I also have code for the UserForm Cancel Control - which IS working
properly.
Results Expected:
1. When selecting OpBtnIVA then Cell D41 will be populated with D39*0.16
(computed value)
Note: D41 is a combined range of cells (D41, D42, E41 and E42) but when
selecting the range (in Excel) the cell is listed as D41.
2. When selecting OpBtnIVAExento then Cell D41 will be populated with the
text EXENTO
Note: D39 is a combined range of cells (D39, D40, E39 and E40) but when
selecting the range (in Excel) the cell is listed as D39
I have tried the following 2 codes in my button but either code is not
functioning.
1st Button Code:
Private Sub ButtonOK_Click()
Dim x As Control
For Each x In Frame1.Controls
If x.Value = "OpBtnIVA" Then
Range(“D41â€).Value = Range("D39") * 0.16
Unload FormIVA
ElseIf x.Value = "OpBtnIVAExento" Then
Range(“D41â€).Value = "EXENTO"
Unload FormIVA
End If
Next
End Sub
2nd Button Code:
Private Sub ButtonOK_Click()
If OpBtnIVA Then Cells(41, D).Value = Cells(39, D).Value * 0.16
If OpBtnIVAExento Then Cells(41, D).Value = "EXENTO"
Unload FormIVA
End Sub
If you need anything else, please indicate. All help is greatly appreciated.
thank you in advance
Maria