Consulting

Results 1 to 4 of 4

Thread: Couple days of work - now lost

  1. #1

    Couple days of work - now lost

    Hello all


    I know this is my first post, but I have been searching for answer to something for couple day now and can't get anything to work.

    I am sorting with auto filter.

    the L column I amd searching for blanks
    The k column I am searching for ends with X

    When the filters come up ...

    Now in VBA I want to search for the visible rows and fill in column L with 554988.

    I have tried a for loop

    for i = 0 to I NEED TO COUNT VISIBLE ROW

    that is the first issue

    the second issue is how do I loop through only the visible cells minus the header and fill them in.

    Any help woudl be GREAT!

  2. #2
    OH yeah i forgot to add I cannot just select colum L through the code and insert because the row numbers vary from 1600 to well over 5000 rows

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Welcome to VBAX
    I'm not sure if this meets your needs
    [vba]Sub Tests()
    Dim LastCell As Range
    Dim Rng As Range
    Set LastCell = Columns(11).Find("x")
    Set Rng = Range(Cells(2, 12), Cells(LastCell.Row, 12))
    Rng.SpecialCells(xlCellTypeBlanks).Offset(, -1).Value = 554998
    End Sub
    [/vba] If not, please post your workbook using Manage Attachments in the Go Advanced reply section.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    After applying the filter
    [VBA]With Range("L:L")
    Range(.Cells(2, 1), .Cells(.Rows.Count, 1).End(xlUp)).SpecialCells(xlCellTypeVisible).Value = 554988
    End With[/VBA]

Posting Permissions

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