Results 1 to 2 of 2

Do While Issue

Threaded View

cadetSean Do While Issue 05-04-2015, 03:01 PM
zbor Re: Do While Issue 05-04-2015, 03:02 PM
  1. #1
    Registered User
    Join Date
    02-18-2015
    Location
    New York
    MS-Off Ver
    2013
    Posts
    2

    Do While Issue

    Hello, I am having a problem with my DoWhile loop where I get the same results each time the code loops. So let's say the Companies A, b, and c should yield 1,2, 3. I am getting 1 for a, b, and c. But when I change the code so it starts at 2, I get b=2 and c=2.

    Sub Macro2()
    '
    ' Macro2 Macro
    '
    
    '
      Dim FileName As String
      Dim FileNames As String
    Dim i As Integer
    
    i = 3
    
           FileName = Cells(i, 1).Value
            FileNames = Cells(i, 2).Value
            
        Do While Cells(i, 1).Value <> ""
        
        Application.DisplayAlerts = False
        
        Range("F2").Select
        Selection.Copy
       
        If Len(Dir("O:\Leasing\PORTFOLIO REPORTS\" & FileName & "")) > 0 Then
        Workbooks.Open FileName:= _
            "O:\Leasing\PORTFOLIO REPORTS\" & FileName & ""
    
        ElseIf Len(Dir("O:\Leasing\PORTFOLIO REPORTS\" & FileName & "")) = 0 Then
        Workbooks.Open FileName:= _
            "O:\Leasing\PORTFOLIO REPORTS\" & FileNames & ""
        
        End If
       
        Range("P6").Select
        Cells.Find(What:=Workbooks("Data Finder.xlsm").Worksheets(1).Range("F2"), After:=ActiveCell, LookIn:=xlFormulas, LookAt _
            :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
            False, SearchFormat:=False).Activate
        ActiveCell.Offset(2, 0).Select
        Application.CutCopyMode = False
        ActiveCell.FormulaR1C1 = "=COUNTIF(R[1]C:R[65524]C,""*SD*"")"
        ActiveCell.Select
        Selection.Copy
        Windows("Data Finder.xlsm").Activate
        Cells(i, 6).Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        
        Windows(2).Activate
        ActiveWindow.Close
        
        i = i + 1
        
        Loop
        Application.DisplayAlerts = True
    
    End Sub
    Attached Images Attached Images
    Last edited by cadetSean; 05-04-2015 at 03:09 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Insert shift down issue macro issue
    By CC64 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-15-2012, 10:57 PM
  2. Issue with X axis values NOT graphing on Scatter graph and issue with Labels
    By lmausolf in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-17-2012, 07:20 AM
  3. Issue - Image button issue - by JBeaucaire
    By Vaibhav in forum Suggestions for Improvement
    Replies: 2
    Last Post: 05-06-2012, 07:35 AM
  4. [SOLVED] Issue - Attachment issue - by Simon Lloyd
    By Vaibhav in forum Suggestions for Improvement
    Replies: 16
    Last Post: 03-16-2012, 06:56 PM
  5. [SOLVED] Issue -Joke thread issue - Mordred
    By Vaibhav in forum Suggestions for Improvement
    Replies: 2
    Last Post: 02-17-2012, 01:31 PM

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