Range name Database only works on one sheet
Worked it out.
Added code for each Command Button to Delete the Name, then re-create with
the new range.
Sheets("Guidance").Select
ActiveWorkbook.Names("Database").Delete
Range("A3:H20").Select
ActiveWorkbook.Names.Add Name:="Database", RefersToR1C1:= _
"=Guidance!R3C1:R20C8"
May be messy, but it worked. Starting to enjoy Excel VBA.
--
Brian McCaffery
"Brian" wrote:
All,
The problem I have is that I have 4 sheets containing data. I want to call
the showdataform from a command buttons based on the sheets. I have named the
range "database" in the first sheet, but if I try to apply it to the second
sheet, then all command buttons pick up the last assigned "database" name. In
other words, is there a way to have the database name in all sheet ranges?
Private Sub CommandButton1_Click()
Range("A3:H33").Name = "Database"
SendKeys "%w", False
ActiveSheet.ShowDataForm
End Sub
Private Sub CommandButton2_Click()
Range("A3:H20").Name = "Database"
SendKeys "%w", False
ActiveSheet.ShowDataForm
End Sub
Thanks,
--
Brian McCaffery
|