VBA code to Import data from 2nd Tab

sharon9999

New Member
Joined
Mar 21, 2017
Messages
20
Hi

VBA code is only taking the data from the 1st tab and importing.
How do I ask it to import the data from the 2nd tab. The aim is to have 2 tabs with different data. Here is the first part of the code for the 1st tab:

Public Sub ImportPayment_Details()

Const ACCOUNT_NAME = "ACCOUNT_NAME"
Const PAYMENT_DATE = "PAYMENT_DATE"
Const PAYMENT_TYPE = "PAYMENT_TYPE"
Const AMOUNT = "AMOUNT"
Const NODE_NAME = "NODE_NAME"


Dim colACCOUNT_NAME As Integer
Dim colPAYMENT_DATE As Integer
Dim colPAYMENT_TYPE As Integer
Dim colAMOUNT As Integer
Dim colNODE_NAME As Integer


Dim foundCell As Range
Dim newWS As Worksheet
Dim wbData As Workbook

Dim filename = "BILL_CYCLE"As String

filename = (Filename)

Set wbData = Workbooks.Open(filename)


So the first tab is Payment Details and the 2nd Order details with the data selected in the code.

TIA

SC
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,215,029
Messages
6,122,760
Members
449,095
Latest member
m_smith_solihull

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