+ Reply to Thread
Results 1 to 3 of 3

Locate blank cells, insert dynamic value

  1. #1
    Registered User
    Join Date
    08-31-2012
    Location
    HK
    MS-Off Ver
    Excel 2003
    Posts
    14

    Locate blank cells, insert dynamic value

    Hi guys,

    Trying to write a macro to achieve the following:

    1. Scan column C until empty cell is located
    2. Insert value 14
    3. if next cell is empty, insert value 13. if next is empty, insert value 12 etc
    4. if next cell NOT empty, then start process again

    was trying to use some dynamic number like:
    range.("C2").select
    dim j%
    if isempty(activecell) then activecell.value=(15-j)
    j=j+1
    activecell.offset(0,1)

    with some looping but can't quite get it right

    any suggestions?

    thanks!

    sampledata.xls

  2. #2
    Registered User
    Join Date
    08-31-2012
    Location
    HK
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Locate blank cells, insert dynamic value

    got it! this may not be the most elegant but for reference:

    Sub horseno()
    Dim j%
    Application.ScreenUpdating = False
    Range("C2").Select
    j = 1
    Do
    If Not IsEmpty(ActiveCell) Then
    ActiveCell.Offset(1, 0).Select
    j = 1
    Else
    ActiveCell.Value = (15 - j)
    j = j + 1
    ActiveCell.Offset(1, 0).Select
    End If
    Loop Until IsEmpty(Cells(ActiveCell.Row, 1))
    End Sub

  3. #3
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Locate blank cells, insert dynamic value

    Try this macro.(Pl see attached file.)

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by kvsrinivasamurthy; 08-14-2013 at 09:36 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Average the last 10 cells of a dynamic column but ignore blank cells & 0
    By mattadler22 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-13-2013, 11:37 PM
  2. Dynamic Name Ranges with blank cells amongst the data
    By hayalperest in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-25-2013, 10:49 AM
  3. Replies: 2
    Last Post: 11-24-2010, 02:47 AM
  4. Advanced filter with blank cells / Dynamic named range with blank cells
    By Jason_2112 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-15-2010, 12:06 PM
  5. Dynamic Named Ranges with Blank Cells
    By andibevan in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-17-2005, 01:48 PM

Tags for this Thread

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