+ Reply to Thread
Results 1 to 4 of 4

Need Loop code to Copy data or pass values

Hybrid View

  1. #1
    Registered User
    Join Date
    02-17-2012
    Location
    Leicester
    MS-Off Ver
    Excel 2007
    Posts
    2

    Need Loop code to Copy data or pass values

    Hi I have inherited some files that will need to be updated monthly. The data is sales information. The problem is it has gaps in columns and rows that need populating. I have tried using a DO/Loop statement with ActiveCell to do this but can't get the logic right. I have attached a spreadsheet with a dummy example of before and after. Accomplishing this with code will save me hours of work each month.
    As you can see my code is flawed but hopefully you can see what I am trying to accomplish.
    If anyone can help I would be really grateful.

    PHP Code: 
    Sub Copydata()
    Dim MyCell As String
    Dim i 
    As Integer
    'i = 2314
    '
    Do Until IsEmpty(Cells(i2))
    For 
    1 To 2314 Step 1
    Range
    ("c3").Select
    MyCell 
    ActiveCell.Value

    If ActiveCell.Offset(10).Value "" Then
    ActiveCell
    .Offset(10).Select
    ActiveCell
    .Value MyCell
        
    Else: ActiveCell.Offset(10).Select
    MyCell 
    ActiveCell.Value

    End 
    If
    ActiveCell.Offset(10).Select
    1

    Next i
    ActiveCell
    .Offset(10).Select
    End Sub

    Attached Files Attached Files

  2. #2
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Need Loop code to Copy data or pass values

    Hey ,

    see if this is what you are after?

    Sub Copydata()
       Dim c01, c02, c03, c04
       Dim rng01 As Range
        Application.ScreenUpdating = 0
         Set rng01 = Cells(5, 1).CurrentRegion
           
             For Each c01 In rng01
                If c01 = "" Then
                   c01.Value = c01.Offset(-1).Value
                End If
             
             Next
        Application.ScreenUpdating = 1
    End Sub
    Attached Files Attached Files
    Last edited by JapanDave; 02-17-2012 at 08:07 AM.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  3. #3
    Registered User
    Join Date
    02-17-2012
    Location
    Leicester
    MS-Off Ver
    Excel 2007
    Posts
    2

    Cool Re: Need Loop code to Copy data or pass values

    Fantastic,
    Thanks for the help. Now I just need to get my head around the code your neat piece of code.
    Really appreciate it.

  4. #4
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Need Loop code to Copy data or pass values

    No problem.
    Please mark the thread as solved in advanced edit.

    And if you need an further help don't hesitate to ask.

+ Reply to Thread

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