Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Jamil Akram   on Feb 12 In MS Office Category.

  
Question Answered By: Lurleen Fischer   on Feb 12

Try this, it doesn't result in the dynamic ranges  you may be looking
for but it correctly deals with any gaps in columns and any gaps in
rows, which CountA doesn't:

Sub blah()
lastcol = Cells(1, Columns.Count).End(xlToLeft).Column
For x = 1 To lastcol
lastrow = Cells(Rows.Count, x).End(xlUp).Row
If Cells(1, x) <> "" Then
With ActiveWorkbook.Names
.Add Name:=Cells(1, x).Value, _
RefersTo:="=Sheet1!" & Range(Sheets("Sheet1").Cells(2, x), _
Sheets("Sheet1").Cells(lastrow, x)).Address
End With
End If
Next x
End Sub

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Problem with named ranges Or get search suggestion and latest updates.


Tagged: