• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

dynamic macro

eluser

New Member
Code:
Sub searchval()

  Dim Val As String
  Dim lngLastRow As Long
  Dim strRowNoList As String
  Dim strColNoList As String
  Dim i As Integer
  Val = "a"
  lngLastRow = Cells(Rows.Count, "A").End(xlUp).row
  For Each cell In Range("A2:A" & lngLastRow)

  If cell.Text = Val Then
  If strRowNoList = "" Then
  strRowNoList = strRowNoList & cell.row
  Else

  strRowNoList = strRowNoList & cell.row
  i = CInt(strRowNoList)
  ActiveWorkbook.Names.Add Name:="a", RefersToR1C1:="=Sheet1!R&i&C1"
  End If
  End If

  Next cell

  'MsgBox strRowNoList

End Sub



--- this workfine but i need to create name range as dynamic row number is given.. please help me on this..

Mod Edit: Question moved to a separate thread, code tags added.
 
Last edited by a moderator:
Can you elaborate on what you mean? Do you need the user to define the lngLastRow, or the start row, or something else?
 
Back
Top