I am trying to use VBA to set an array based on a cell value in my workbook. I have an Array set on my data called THREEMO. For this month the value is Aug. I want to add a Sheet named Aug and then set an array for Columns B:C and name them Aug as well. I was able to add the sheet and name it but the array is not letting me use the variable to name the array. Here is what I have so far:
Dim WS As Worksheet
Set WS = Sheets.Add(After:=Sheets(Worksheets.Count))
WS.Name = Range("THREEMO")
Dim stNewTab As String
stNewTab = Range("THREEMO")
'Set Arrays
Columns("B:C").Select
ActiveWorkbook.Names.Add Name:=Range("THREEMO"), RefersToR1C1:="=Range("THREEMO")!C2:C3"
I am getting the error on the "'Set Arrays" section. This is what it looks like when I record the macro, so I am just having trouble setting up RefersToR1C1 with the variable for the month:
ActiveWorkbook.Names.Add Name:="AUG", RefersToR1C1:="=Aug!C5:C6"
RefersToR1C1:="=Range("THREEMO")!C2:C3"toRefersToR1C1:=Range("THREEMO") & "!C2:C3"