i need help with the attached file and its code.
the below code, does create dynamic range, but with defects, where if the data has empty cells then it does not work.
i need help with modification of below code, so that it takes care of the empty cells as well. so that in each column it the dynamic range encompasses the last row that has data in it.
'Creates range names based on header row information
Dim wbk As Workbook
Dim sht As Worksheet
Dim rng, rng2 As Range
Dim cl As Object
Dim c As Long
Dim strAddr As Variant
Dim strShName, strHdrName, strCol As String
Set wbk = ActiveWorkbook
For Each sht In wbk.Sheets
c = sht.Cells.SpecialCells(xlLastCell).Column
Set rng = sht.Range("A1", sht.Range("A1").Offset(0, c))
For Each cl In rng
If cl.Value <> "" Then
strShName = Replace(sht.Name, " ", "_", 1)
strHdrName = Replace(cl.Value, " ", "_", 1)
strAddr = Split(cl.Address, "$")
strCol = "$" & strAddr(1) & ":$" & strAddr(1)
Set rng2 = sht.Range(cl, cl.End(xlDown))
ActiveWorkbook.Names.Add Name:=strShName & strHdrName, _
RefersTo:="=OFFSET('" & sht.Name & "'!" & cl.Address & ",0,0,COUNTA('" & _
sht.Name & "'!" & strCol & "),1)"