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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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