Results 1 to 4 of 4

Loop increase with end only on blank

Threaded View

Sc0tt1e Loop increase with end only... 03-13-2014, 09:43 AM
Sc0tt1e Re: Loop increase with end... 03-13-2014, 11:55 AM
Sc0tt1e Re: Loop increase with end... 03-14-2014, 09:45 AM
Sc0tt1e Re: Loop increase with end... 03-14-2014, 10:23 AM
  1. #1
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    640

    Loop increase with end only on blank

    Ok guys and gals, I've managed to put together the below code and have come to a point where further assiatance is required.

    It uses a userform to find a saved document and paste the info into a database for specific cases. I have my set templates and they have defined columns but correspondence that are manually created (or received) need to be saved into a cell in the case row but there could only be 2 letters on one case and maybe 100 letters on another.

    I am trying to find a way to carry out the below on an expenential basis. Search for the first cell, if it is blank move on 3 and keep going until you find an empty cell then paste the values in the two defined cells.

    Can anyone work out how this can be done because I have spent a good couple of days thinking it through and have come up with nadda.

    Private Sub CommandButton2_Click()
    Dim UserId as String
    Dim CaseId as String
    Dim SearchString As String
    
       UserId = Letters.User.Value
       CaseId = Letters.CaseNo.Value
       
    SearchString = UserId & CaseId
    
    i = 85
    
    '   Search Case Reference Number column from database based on two values in Userform
    '
    
    '
            Letters.Browse.Copy
            
                    If Sheets("Database").Cells(WorksheetFunction.Match(SearchString, Sheets("Database").Range("B:B"), 0), i).Value = "" Then
            
    On Error Resume Next
    Sheets("Database").Cells(WorksheetFunction.Match(SearchString, Sheets("Database").Range("B:B"), 0), i).Value = Letters.Browse.Value
    Sheets("Database").Cells(WorksheetFunction.Match(SearchString, Sheets("Database").Range("B:B"), 0), i + 1).Value = Letters.Description.Value
    On Error GoTo 0
        
    Else
    
    On Error Resume Next
    Sheets("Database").Cells(WorksheetFunction.Match(SearchString, Sheets("Database").Range("B:B"), 0), i + 3).Value = Letters.Browse.Value
    Sheets("Database").Cells(WorksheetFunction.Match(SearchString, Sheets("Database").Range("B:B"), 0), i + 4).Value = Letters.Description.Value
    On Error GoTo 0
    
    End If
            
            Letters.Hide
    
    End Sub
    Last edited by Sc0tt1e; 03-13-2014 at 09:46 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Increase copy and paste range after each loop
    By JakeSn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-27-2014, 04:34 AM
  2. [SOLVED] Increase letter value each loop.
    By Rob* in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-07-2013, 03:17 AM
  3. [SOLVED] For...Next loop - trying to have named range increase by count of 1
    By seaveegee in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2012, 02:06 PM
  4. Looking to increase cells in loop
    By djhatrick12 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-06-2011, 04:11 PM
  5. Increase Loop Efficiency/Loop Alternative
    By nsorden in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-19-2009, 09:54 AM

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