how to give variable range

  • Thread starter Thread starter ezil
  • Start date Start date
E

ezil

i need the code for doing this..please help
i= 2 to 20 (variable)
ActiveWorkbook.Names.Add Name:="abc", RefersTorange= cells(1,1),cells(i,1)
 
i = 5
Set myrange = Range("A1", Cells(1, i))
ActiveWorkbook.Names.Add Name:="abc", RefersTo:="=" & myrange.Address
 
Better to use an offset formula such as =offset($a$1,0,0,counta($a:$a)) but
to answer.

Sub namerng()
mc = "b"
lr = cells(Rows.Count, mc).End(xlUp).Row
Range(cells(1, mc), cells(lr, mc)).Name = "abc"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top