• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How can we copy data while skipping few column each time?

Hello
This time on just how to copy by skipping same number of column each time.

Friend I have a small code below which copy Actual hours highlighted in (Blue) from actual vs plan tab to Burn macro tab and paste on respective dates in burn tab ('date for which hour belongs to which should be same as on actuals tab), also you can see in the attached Actual vs plan tab file that actual hour column is in each week I want only those hours.

I have a small code below as well as in the attached file which is copy all the hours.

Actual vs Plan is the main tab however burn is just the copy of actual hours from that tab for each week.

Below is the code which I have managed to come up with and you can also see in the attached file.

Thank you
Akash

Code:
Dim myRange As Range
Dim myCell As Range
Dim fcell As Range
Dim lcell As Range
Dim myrange2 As Range
Dim mycell2 As Range
Dim paste_start As Long

Set fcell = Range(Sheets("BurnMacro").Range("B5").Value)
Set lcell = Range(Sheets("BurnMacro").Range("C5").Value)

'below code to pull hours
Set hstrtcell = Range(Sheets("BurnMacro").Range("H2").Value)
Set hlstcell = Range(Sheets("BurnMacro").Range("I2").Value)
Set myrange2 = Worksheets("Actual vs Plan").Range(hstrtcell.Address, hlstcell.Address)
paste_start = 8
For Each mycell2 In myrange2
Sheets("actual vs Plan").Activate
        'If mycell2.Value = Sheets("BurnMacro").Range("C3").Value And mycell2.EntireRow.Hidden = False Then
        Sheets("Actual vs Plan").Range(Cells(mycell2.Row, hstrtcell.Column), Cells(mycell2.Row, hlstcell.Column)).Offset(0, 0).Copy Destination:=Sheets("BurnMacro").Range("H" & paste_start)
        paste_start = paste_start + 1
        'End If
  Next mycell2
 

Attachments

  • Book4 - Copy.xlsm
    31.4 KB · Views: 2
I thought the old post became more confusing and this time I only want to know how we can skip from one column to another which we need to add i think on this line of code.

Code:
For Each mycell2 In myrange2
Sheets("actual vs Plan").Activate
        'If mycell2.Value = Sheets("BurnMacro").Range("C3").Value And mycell2.EntireRow.Hidden = False Then
      Sheets("Actual vs Plan").Range(Cells(mycell2.Row, hstrtcell.Column), Cells(mycell2.Row, hlstcell.Column)).Offset(0, 0).Copy Destination:=Sheets("BurnMacro").Range("H" & paste_start)
        paste_start = paste_start + 1
        'End If

I will remove the old post.

Thank you
Akash
 
Back
Top