Click here to Skip to main content
13,090,930 members (47,449 online)
Rate this:
Please Sign up or sign in to vote.
See more:

I am having a problem with the following.

I am trying to

1. create 2 excel to do this
2. Add a heading (which are the same) on both worksheets e.g. Name, Address
3. Select a worksheet and populate with an array
4. When the records populated are greater than 20,000 then select worksheet 2 to populate the rest

I can do this no bother when just the one worksheet but seem to have got myself all confused when trying the above.
Posted 8-Apr-13 1:25am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Im assuming that you have some sort of code as this:
Dim oXL As Excel.Application
        Dim oWB As Excel.Workbook
        Dim oSheet As Excel.Worksheet
        Dim oRng As Excel.Range
        ' Start Excel and get Application object.
        oXL = CreateObject("Excel.Application")
        oXL.Visible = True
        ' Get a new workbook.
        oWB = oXL.Workbooks.Add
        oSheet = oWB.ActiveSheet

You can set the first sheet with the command:
oSheet = oWB.Sheet(1)

and the second by:
oSheet = oWB.Sheet(2)
Central_IT 8-Apr-13 7:50am
Thanks for getting back with a quick reply.
Your solution works perfect. Just a wee question,
How can you in a loop display the headings and then the data?
Kenneth Haugland 8-Apr-13 7:53am
Just loop through the cells and read the header information?
Please see this:
Central_IT 8-Apr-13 8:42am
Thanks yet again for the required information. There is enough info there to solve my problem.
Central_IT 8-Apr-13 8:43am
Should have been 5 stars but not allowing me over 4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170813.1 | Last Updated 8 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100