+ Reply to Thread
Results 1 to 12 of 12

Cycle throuhg rows on a sheet

Hybrid View

  1. #1
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,432

    Re: Cycle throuhg rows on a sheet

    The original example code demonstrated looping through rows on each sheet. The second example just gets one row of data from each sheet, which appeared to be what was (not) present in your sample workbook.

    I suggest you have a go at combining the row loop into the sheet loop.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  2. #2
    Forum Contributor
    Join Date
    12-08-2012
    Location
    USA
    MS-Off Ver
    Excel 365
    Posts
    190

    Re: Cycle throuhg rows on a sheet

    Ok im lost woith what to do from her..i can get them to combine well
    Option Explicit
    
    Sub SampleLoop()
    
    Const sSSName As String = "Labels"
    Dim sh As Worksheet
    Dim lLR As Long
    Dim i As Long
    
    For Each sh In ThisWorkbook.Worksheets
        With sh 'do this to each sheet
            If sh.Name <> sSSName Then ' if the sheet doesnt equal label sheet
            With Sheets(sSSName) ' label sheet
                lLR = .Range("A" & .Rows.Count).End(xlUp).Row 'bottom row on the labels sheet
                For i = 1 To lLR
                    .Range("A" & i).Value = sh.Range("A" & (i + 3)) & Chr(10) & _
                                            sh.Range("B" & (i + 3)) & Chr(10) & _
                                            sh.Range("C" & (i + 3)) & Chr(10)
                    If sh.Range("D" & (i + 3)) = "" Then
                        .Range("A" & i).Value = .Range("A" & i).Value & "Det. 2014"
                    Else
                        .Range("A" & i).Value = .Range("A" & i).Value & sh.Range("D" & (i + 3)) & _
                                                                        Chr(10) & _
                                                                        "Det. R. G. Ahlers 2014"
                    End If 'Sheets(sSSName).Range("D4")
                Next 'i
                End With
            End If 'sh.Name
        End With 'sh
    Next 'sh
    
    End Sub

+ 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. [SOLVED] Cycle Through A Series of Worksheets & Insert Rows, Then Special Paste Data
    By DDM64 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-26-2012, 10:45 PM
  2. [SOLVED] Cycle Through Specific Worksheets & Paste Data In Each Sheet
    By DDM64 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-18-2012, 11:59 PM
  3. [SOLVED] Cycle through a long set of output and select certain rows/columns for new sheets
    By matrix_machine in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2012, 05:32 PM
  4. cycle through data from another sheet
    By vinnybear in forum Excel General
    Replies: 6
    Last Post: 02-11-2012, 11:34 AM
  5. [SOLVED] How do I keep result from 1 iteration cycle to use in next cycle?
    By sgl8akm in forum Excel General
    Replies: 0
    Last Post: 07-27-2006, 03:35 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