Excel interface to SQL

P

Paul

I have a Excel file with multiple worksheets on it, each worksheet is setup
with the same layout and is linked to other Excel files. I can select
multiple worksheets at one time by holding the "Ctrl" key while selecting
the worksheet. I need to save the data from the selected worksheet to a Sql
database. First, how do I write a "For...Loop" on the selected worksheet
using VBA in Excel, then how do I select some variables on a range of cell
value from the selected worksheet and pass on as a parameters to a Sql store
procedure. I am going to create a new button on the Excel main menu to
execute this. Thanks.
 
S

Shane Devenshire

Hi,

can't help you with the SQL, but Excel has the following basic loop
structures:

1.

For Each sh in Worksheets

Next sh

2.

For I = 1 to 10

Next I

3.

Do While ActiveCell <>""

Loop

4.

Do Unti ActiveCell = ""

Loop

5.

Do

Loop While ActiveCell < 20

6.

Do

Loop Until ActiveCell > 10

7.

While Counter < 20


Wend

Add your own code between.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top