Hello Everyone!
This is my first question posted, so sorry if it is not aesthetically pleasing.
I am in the process of making a sub or two to create named ranges based on data in one worksheet, and then transfer it to another worksheet. I have working code below, but I do not wish to type out all of the named ranges and believe there is a way to automate this process.
Here's what I have thus far:
Sub NR()
'Creates named ranges based on parameter name, then assigns the data below that parameter to that name.
For i = 1 To 369
For j = 1 To 369
ActiveWorkbook.Names.Add _
Name:=Sheets("Sheet1").Cells(1, i).Value & "Range", _
RefersTo:=Sheets("Sheet1").Cells(j, i)
Next j
Next i
End Sub
Sub CopyPasta()
Sheets("Sheet1").Columns(Range("howRange").Column).Copy
Sheets("Sheet2").Select
Range("A1").Select
ActiveSheet.Paste
End Sub
Sheet 1 in my workbook is a sheet that has 100's of columns of data, where each of those columns is a named range. It has rows 2:44 of data for each of those columns, in which the named range is assigned to.
In the Sub CopyPasta(), I paste the first named range of sheet 1 onto sheet 2. This works well, but would be very annoying to add a section like this for every named range in sheet 1.
How should I go about automating this process?
Thank you for your time!
This is my first question posted, so sorry if it is not aesthetically pleasing.
I am in the process of making a sub or two to create named ranges based on data in one worksheet, and then transfer it to another worksheet. I have working code below, but I do not wish to type out all of the named ranges and believe there is a way to automate this process.
Here's what I have thus far:
Sub NR()
'Creates named ranges based on parameter name, then assigns the data below that parameter to that name.
For i = 1 To 369
For j = 1 To 369
ActiveWorkbook.Names.Add _
Name:=Sheets("Sheet1").Cells(1, i).Value & "Range", _
RefersTo:=Sheets("Sheet1").Cells(j, i)
Next j
Next i
End Sub
Sub CopyPasta()
Sheets("Sheet1").Columns(Range("howRange").Column).Copy
Sheets("Sheet2").Select
Range("A1").Select
ActiveSheet.Paste
End Sub
Sheet 1 in my workbook is a sheet that has 100's of columns of data, where each of those columns is a named range. It has rows 2:44 of data for each of those columns, in which the named range is assigned to.
In the Sub CopyPasta(), I paste the first named range of sheet 1 onto sheet 2. This works well, but would be very annoying to add a section like this for every named range in sheet 1.
How should I go about automating this process?
Thank you for your time!