Modify existing VBA to transfer data over

Status
Not open for further replies.

ItalianPlatinum

Well-known Member
Joined
Mar 23, 2017
Messages
793
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello - I have existing VBA that works as intended transferring data over to another sheet. i have to add a 2nd occurrence of a transfer from another sheet. Therefore I am having difficulty to transfer over to the next open row of the destination sheet. is anyone also to assist?


VBA Code:
Sub ImportFILE()
    Dim vCols As Variant, vRows As Variant
    Dim i As Long, k As Long
    
'Fomulas for Review (PD File)
With WsSPT1
'worksheet ETC formulas, filters, column mods'
End With

'transfer PD data over to Compare tab
  vCols = Array(1, 2, 3, 4, 8, 9, 10, 11) '<- Columns of interest in specified order
  With WsSPCT
    With .Range("A1:K" & .Range("H" & rows.count).End(xlUp).row)
        If .rows.count > 2 Then
            vRows = Application.Index(.Cells, Evaluate("row(1:" & .rows.count & ")"), Array(8, 3))
            For i = 3 To UBound(vRows)
                If Len(vRows(i, 1)) > 0 And UCase(vRows(i, 2)) <> "" Then
                    k = k + 1
                    vRows(k, 1) = i
        End If
      Next i
      WsDIST.Range("A2").Resize(k, UBound(vCols) + 1).Value = Application.Index(.Cells.Value, Application.Index(vRows, 0, 1), vCols)
      Else
        MsgBox "No data to transfer"
      End If
    End With
  End With

'Fomulas for Review (CD File)
With WsSPT
'worksheet ETC formulas, filters, column mods'
End With

'NEED HELP ON THIS! transfer CD data over to Compare tab BELOW PD data
  vCols = Array(1, 2, 3, 4, 8, 9, 10, 11) '<- Columns of interest in specified order
  With WsSPT
    With .Range("A1:K" & .Range("H" & rows.count).End(xlUp).row)
        If .rows.count > 2 Then
            vRows = Application.Index(.Cells, Evaluate("row(1:" & .rows.count & ")"), Array(8, 3))
            For i = 3 To UBound(vRows)
                If Len(vRows(i, 1)) > 0 And UCase(vRows(i, 2)) <> "" Then
                    k = k + 1
                    vRows(k, 1) = i
        End If
      Next i
      WsDIST.Range("A2").Resize(k, UBound(vCols) + 1).Value = Application.Index(.Cells.Value, Application.Index(vRows, 0, 1), vCols)
      Else
        MsgBox "No data to transfer"
      End If
    End With
  End With
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Status
Not open for further replies.

Forum statistics

Threads
1,214,918
Messages
6,122,255
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top