Results 1 to 7 of 7

Loop issue when cell value is null

Threaded View

  1. #1
    Registered User
    Join Date
    02-20-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    92

    Loop issue when cell value is null

    Hey,

    I'm trying to run a loop which will do something when there is a value in the cell, but skip the cell (or delete the row) when there is no value.

    I pulled this from another thread, but it isn't working for me:

     Sub DeleteBlankRows()
    'Evaluates column A only
    
    Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete xlShiftUp
    
    End Sub
    I think it might be because my blank cells have a formula, so they aren't really blank? I have a formula like this: =IF(M2="Yes",I2,"")

    Here is the part of code I am trying to loop through in case my above description is not enough information (only the beggining is giving me trouble, and the red section could change depending if I delete the rows or skip them):

     Application.DisplayAlerts = False
    
    Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete xlShiftUp
    
    'new
    Range("A2").Select
    
    'new
    Do Until ActiveCell.Value = ""
    
    
    'new
    currentfund = ActiveCell.Value
    
    Dim MonarchObj As Object
    Dim openfile, openmod, t As Boolean
    
    'If Monarch is currently active GetObject will use Monarch. If it is not use the CreateObject() to
    'open another copy of Monarch.
    Set MonarchObj = GetObject("", "Monarch32")
    If MonarchObj Is Nothing Then
        Set MonarchObj = CreateObject("Monarch32")
    End If
    t = MonarchObj.SetLogFile("C:\Temp\MPrg_G5.log", False)
    
    
    '----------------------------------------
    'Edit below this line
    
    
    
    openfile = MonarchObj.SetReportFile("c:\TEMP\r104" & currentfund & ".exp", False)
    
    If openfile = True Then
        
    openmod = MonarchObj.SetModelFile("\\fpcmsbos212vs1\vol1\common\shared\Templates and Macros\Monarch Models\R104.MOD")
    
    If openmod = True Then
    
    'Set filter for each frame and export to Excel
    
    'MonarchObj.CurrentFilter = "Amount"
    
    MonarchObj.ExportTable ("\\fpcmsbos212vs1\vol1\common\shared\Templates and Macros\Macros\Term CATs\Downloads\r104" & currentfund & ".xls")
    
    End If
    End If
    
    
    MonarchObj.Exit
    
    'new
    ActiveCell.Offset(1, 0).Select
    
    Loop
    Last edited by starcraftbud; 10-07-2009 at 10:10 AM.

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