Results 1 to 5 of 5

Finging first row of a given column that has data in it.......exclude header

Threaded View

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Finging first row of a given column that has data in it.......exclude header

    I have this code and it works to find the first row of data in colB where it excludes the header row.


    first_data_row = ws.Cells.Find(What:="*", After:=[B1], SearchOrder:=xlByColumns, SearchDirection:=xlNext).Row

    However, when i try to make the code more flexible by makeing B1 a variable .....i get a type mismatch........see below

    Dim study_col As Integer
    
    fl_name = ThisWorkbook.Name
    Set ws = Workbooks(fl_name).Worksheets("Sheet1")
    Set ws3 = Workbooks(fl_name).Worksheets("Sheet3")
    study_col = 2
    'first_data_row = ws.Cells.Find(What:="*", After:=[B1], SearchOrder:=xlByColumns, SearchDirection:=xlNext).Row
    first_data_row = ws.Cells.Find(What:="*", After:=[alphacol(study_col) & "1"], SearchOrder:=xlByColumns, SearchDirection:=xlNext).Row
    MsgBox (first_data_row)



    I am enclosing an excel file as this usually makes things easier.
    Attached Files Attached Files
    Last edited by welchs101; 07-14-2011 at 02:23 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1