Hi guys
first I have combobox contains sheets names , but should show ranges names and I have textbox1,2,3
so when I select the range name wherever(somtimes two ranges names in the same sheet or each range is in every sheet )
for instance range name(DATA) should copy from textboxes to columns A2:D for range name(DATA) , and range name(source) should copy from textboxes to columns H2:K range name(source) .both ranges name are existed in TRANSACTION sheet name
another range name(EXPORT) should copy from textboxes to columns C2:F for range name(EXPORT) in OUTPUT sheet name .
so what I need :
1- populate all of the ranges names are existed in specific sheets(TRANSACTION, OUTPUT) if it's possible without using helper column for ranges names.
2-when select specific range name from combobox1 implement the code for selected range name
first I have combobox contains sheets names , but should show ranges names and I have textbox1,2,3
so when I select the range name wherever(somtimes two ranges names in the same sheet or each range is in every sheet )
for instance range name(DATA) should copy from textboxes to columns A2:D for range name(DATA) , and range name(source) should copy from textboxes to columns H2:K range name(source) .both ranges name are existed in TRANSACTION sheet name
another range name(EXPORT) should copy from textboxes to columns C2:F for range name(EXPORT) in OUTPUT sheet name .
so what I need :
1- populate all of the ranges names are existed in specific sheets(TRANSACTION, OUTPUT) if it's possible without using helper column for ranges names.
2-when select specific range name from combobox1 implement the code for selected range name
VBA Code:
Private Sub CommandButton1_Click()
Dim lr As Long, sh As Worksheet
'Dim Cl As Range
If ComboBox1.Value = "" Then Exit Sub
Set sh = Sheets(ComboBox1.Value)
With sh
.Activate
lr = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("B" & lr + 1) = TextBox1.Value
.Range("C" & lr + 1) = TextBox2.Value
.Range("D" & lr + 1) = TextBox3.Value
.Range("E" & lr + 1) = TextBox4.Value
.Range("A" & lr + 1) = lr
.Columns(1).NumberFormat = "General"
End With
End Sub