Hi Guys,
I've heard a bit about defining ranges lately and i wanted to get a feel for how they are actually useful.
When i say defining ranges, I am talking specifically about the following:
I have macro which is run on many different spreadsheets - all in the same format. Currently, I have several formulas like:
"=SUMPRODUCT(--($C1:$C65535=""PKT""),--($N1:$N65535=""Internet""),($R1:$R65535))"
Now i've heard that what this formula is actually doing is searching EVERY single cell in Column C for instances of PKT etc, and that if i defined column C as a range (lets say "Call Type") then it would automatically only search all of the USED cells in that range. Is that right? And if so, is that likely to speed the macro up?
I had a quick look at defining names and found this:
but the problem is that the "=Sheet1!C4" section is variable as the active sheet name will always be different. Is there a way to make it read the active sheet name, instead of just Sheet1?
And my last question (i promise) is - Is there a way to automatically define each used column as a separate range, and call that range name the value of row1 in that range? (i.e - Cell A1 is called Date, so can i automatically define Column A as a range that is called Date? - Plus, some of the cells in row 1 will have a space in it (Call Type) - can i replace the space with an "_" (underscore)?
Thanks so much for your help guys.
Appreciate any feedback given
I've heard a bit about defining ranges lately and i wanted to get a feel for how they are actually useful.
When i say defining ranges, I am talking specifically about the following:
I have macro which is run on many different spreadsheets - all in the same format. Currently, I have several formulas like:
"=SUMPRODUCT(--($C1:$C65535=""PKT""),--($N1:$N65535=""Internet""),($R1:$R65535))"
Now i've heard that what this formula is actually doing is searching EVERY single cell in Column C for instances of PKT etc, and that if i defined column C as a range (lets say "Call Type") then it would automatically only search all of the USED cells in that range. Is that right? And if so, is that likely to speed the macro up?
I had a quick look at defining names and found this:
Code:
Columns("D:D").Select
ActiveWorkbook.Names.Add Name:="ColumnD", RefersToR1C1:="=Sheet1!C4"
And my last question (i promise) is - Is there a way to automatically define each used column as a separate range, and call that range name the value of row1 in that range? (i.e - Cell A1 is called Date, so can i automatically define Column A as a range that is called Date? - Plus, some of the cells in row 1 will have a space in it (Call Type) - can i replace the space with an "_" (underscore)?
Thanks so much for your help guys.
Appreciate any feedback given