Ashwinghan
New Member
Hello,
I have three excel sheets in a workbook. The first sheet is kind of a form with Active X controls(ComboBox and CheckBoxes). The second sheet is the main data sheet which can be viewed in the attached file.
I need a code where in If I select Room name b or any room in the ComboBox and turn on the checkBoxes for Furniture or Dimension or Gases, The corresponding values for that room should be copied to 3rd row of Sheet 3 as in the attached file. No matter what selection I make in the Room name, the room name and the checked boxes values should always be copied to row 3 on Sheet 3. I have started with a basic code but I need to improvise this. (i.e instead of having an if statement for every value, How can I have a single if statement so that It would work for more rows and columns too).
Here is the code which has to be optimized. You can also look it up in the attached file.
Looking forward for your help
Thanks
Ashwin
I have three excel sheets in a workbook. The first sheet is kind of a form with Active X controls(ComboBox and CheckBoxes). The second sheet is the main data sheet which can be viewed in the attached file.
I need a code where in If I select Room name b or any room in the ComboBox and turn on the checkBoxes for Furniture or Dimension or Gases, The corresponding values for that room should be copied to 3rd row of Sheet 3 as in the attached file. No matter what selection I make in the Room name, the room name and the checked boxes values should always be copied to row 3 on Sheet 3. I have started with a basic code but I need to improvise this. (i.e instead of having an if statement for every value, How can I have a single if statement so that It would work for more rows and columns too).
Here is the code which has to be optimized. You can also look it up in the attached file.
Code:
Private Sub CheckBox1_Click()
If ComboBox1.Value = "a" And CheckBox1.Value = True Then
Sheets("Sheet1").Range("D3").Copy Sheets("Sheet3").Range("D3")
End If
If ComboBox1.Value = "b" And CheckBox1.Value = True Then
Sheets("Sheet1").Range("D4").Copy Sheets("Sheet3").Range("D3")
End If
If ComboBox1.Value = "c" And CheckBox1.Value = True Then
Sheets("Sheet1").Range("D5").Copy Sheets("Sheet3").Range("D3")
End If
If ComboBox1.Value = "d" And CheckBox1.Value = True Then
Sheets("Sheet1").Range("D6").Copy Sheets("Sheet3").Range("D3")
End If
If ComboBox1.Value = "e" And CheckBox1.Value = True Then
Sheets("Sheet1").Range("D7").Copy Sheets("Sheet3").Range("D3")
End If
If CheckBox1.Value = False Then
Sheets("Sheet3").Range("D3").Delete
End If
End Sub
Looking forward for your help
Thanks
Ashwin