white_flag
Active Member
- Joined
- Mar 17, 2010
- Messages
- 331
Hello
I have two dynamic ranges defined via VBA. But like this it is not going.
Then I put just one range "name1" and in excel the dynamic range become:
=OFFSET(data!$B$3,0,0,COUNTA(data!$B28:$B45),1) insted
=OFFSET(data!$B$3,0,0,COUNTA(data!$B3:$B20),1)
so what it is wrong?
I have two dynamic ranges defined via VBA. But like this it is not going.
Code:
Option Explicit
Public Sub list_name()
ActiveWorkbook.Names.Add Name:="name1", RefersTo:="=OFFSET(data!$B$3,0,0,COUNTA(data!$B3:$B20),1)"
ActiveWorkbook.Names.Add Name:="name2", RefersTo:="=OFFSET(data!$B$26,0,0,COUNTA(data!$B26:$B38),1)"
With Sheets("Calculation").Range("C6").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=name1"
.IgnoreBlank = True
.InCellDropdown = True
End With
With Sheets("Calculation").Range("C7").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=name2"
.IgnoreBlank = True
.InCellDropdown = True
End With
End Sub
=OFFSET(data!$B$3,0,0,COUNTA(data!$B28:$B45),1) insted
=OFFSET(data!$B$3,0,0,COUNTA(data!$B3:$B20),1)
Code:
Option Explicit
Public Sub list_name()
ActiveWorkbook.Names.Add Name:="name1", RefersTo:="=OFFSET(data!$B$3,0,0,COUNTA(data!$B3:$B20),1)"
With Sheets("Calculation").Range("C6").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=name1"
.IgnoreBlank = True
.InCellDropdown = True
End With
End Sub