Results 1 to 5 of 5

Help with nested loops

Threaded View

wishmaker Help with nested loops 04-10-2013, 05:40 AM
Norie The description and the code... 04-10-2013, 05:58 AM
wishmaker Re: Help with nested loops 04-10-2013, 07:35 AM
wishmaker Re: Help with nested loops 04-23-2013, 10:41 AM
Norie Re: Help with nested loops 04-23-2013, 11:03 AM
  1. #1
    Registered User
    Join Date
    11-12-2009
    Location
    surrey
    MS-Off Ver
    Excel 2003
    Posts
    22

    Cool Help with nested loops

    I’ll try and shorten the task to its smallest part as each source row has 52 columns and I have 1000’s of row to reformat.

    I need to copy data from
    sheet1 Row1 columns ABCD to sheet2 row 1 and repeat like this
    Row1 columns ABCE to sheet2 row 2
    Row1 columns ABCG to sheet2 row 3

    then go to next row (2) in sheet 1 and repeat
    Row2 columns ABCD to sheet2 row 4 and repeat like this
    Row2 columns ABCE to sheet2 row 5
    Row2 columns ABCG to sheet2 row 6

    I've started with the code below then really got stuck with how to procede. Any help would be greatly appreciated.
      Sub InvoiceCosts()
    
    Dim MyLastRow As Long, x As Long, j As Long
    Dim BGTree As Long, BGName As String, RG As String, DateFrom As Date, DateTo As Date
    Dim PeriodDate As Date, Period As Date, Balance As Integer
    Dim sWBU As Worksheet
    Dim sWBUT As Worksheet
    j = 12
    
    Set sWBU = Worksheets("Wish Budg To Be uploaded") ' Name of worksheets for data source
    Set sWBUT = Worksheets("Test") ' Name of worksheets for data destination
    
    MyLastRow = sWBU.Cells(Application.Rows.Count, 2).End(xlUp).Row 'Find Final Row in dataset
    
    BGTree = sWBU.Cells(j, 4).Value
    BGName = sWBU.Cells(j, 12).Value
    DateFrom = sWBU.Cells(j, 6).Value
    DateTo = sWBU.Cells(j, 7).Value
    PeriodDate = sWBU.Cells(j, 5).Value
    Period = sWBU.Cells(j, 8).Value
    Balance = sWBU.Cells(j, 16).Value
    
    'MsgBox BGTree
     x = 2 'To 52 'MyLastRow
    sWBUT.Cells(x, 1).Value = BGTree
    sWBUT.Cells(x, 2).Value = BGName
    sWBUT.Cells(x, 3).Value = BGTree
    sWBUT.Cells(x, 4).Value = BGTree
    sWBUT.Cells(x, 5).Value = BGTree
    sWBUT.Cells(x, 6).Value = BGTree
    sWBUT.Cells(x, 7).Value = BGTree
    sWBUT.Cells(x, 8).Value = BGName
    sWBUT.Cells(x, 9).Value = "Range"
    sWBUT.Cells(x, 11).Value = DateFrom
    sWBUT.Cells(x, 12).Value = DateTo
    sWBUT.Cells(x, 13).Value = PeriodDate
    sWBUT.Cells(x, 14).Value = Period
    sWBUT.Cells(x, 15).Value = Balance
    sWBUT.Cells(x, 17).Value = Balance
    'Next x
    Last edited by wishmaker; 04-23-2013 at 10:43 AM. Reason: Solved

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