Is a macro possible here?

D

Dan

I own a small company where my we get inquiries on a daily business
and we open the .csv files with rows like the following. An employee
places each in individual worksheets in one workbook (normally there
are approx. 12 rows of information):

A B
1 Information Input Column
2 Inquirer John Doe
3 Phone Number 123-123-1234
4 Email (e-mail address removed)

We have 80-100 worksheets in one document at the end of the month.

My database is the first worksheet in the workbook, called
DBworksheet, followed by the 80-100 individual worksheets of
inquiries.

The header of the DBworksheet is:

INQUIRER STNUMBER STNAME CITY
STATE ZIP

The first inquiry worksheet, which is the second worksheet has a tab
titled Doe_John

To populate the first row under the header with the information of the
Doe_John worksheet, I have the formulas:

=Doe_John!$B$2 =Doe_John!$B$3 =Doe_John!$B$4

As of now, I am scrolling down and filling the number of rows with the
number of worksheets I have and manually doing a repair/replace in the
function.

For instance, the 2nd inquiry worksheet is Smith_Joyce. After using
fill I highlight the copied Doe_John row and find/replace by:

Find: Doe_John
Replace: Smith_Joyce

Each function with Doe_John is replaced with Smith_Joyce:

=Smith_Joyce!$B$2 =Smith_Joyce!$B$3 =Smith_Joyce!$B$4

My row after John Doe is populated now with Joyce Smith.

Is there a way I can create a macro that counts how many inqury
worksheets I have, fills the rows and then does a find/replace based
on each tab name so I don't have to do it manually?

Thanks,

Dan
 
A

akphidelt

Can you explain why exactly you are creating 60+ worksheets with 1 worksheet
per person?
 
J

Joel

I created formulas like you did in the example. You can also hard copy the
value into the DBworksheet. I did only three rows of data, you can add up to
the 10 rows as needed.


Sub create_db()

RowCount = 1
For Each sht In ThisWorkbook.Sheets
If sht.Name <> "DBworksheet" Then
With Sheets("DBworksheet")
.Range("A" & RowCount).Formula = _
"=" & sht.Name & "!$B$2"
.Range("B" & RowCount).Formula = _
"=" & sht.Name & "!$B$3"
.Range("C" & RowCount).Formula = _
"=" & sht.Name & "!$B$4"
End With
RowCount = RowCount + 1
End If
next sht
End Sub
 
D

Dan

Right or wrong, that's how the web-form returns and the process
evolved.

Further, that is how we start our account paperwork, printing each one
is our cover.
 
D

Dan

Thanks, I'll give it a try!

I created formulas like you did in the example. You can also hard copy the
value into the DBworksheet. I did only three rows of data, you can add up to
the 10 rows as needed.


Sub create_db()

RowCount = 1
For Each sht In ThisWorkbook.Sheets
If sht.Name <> "DBworksheet" Then
With Sheets("DBworksheet")
.Range("A" & RowCount).Formula = _
"=" & sht.Name & "!$B$2"
.Range("B" & RowCount).Formula = _
"=" & sht.Name & "!$B$3"
.Range("C" & RowCount).Formula = _
"=" & sht.Name & "!$B$4"
End With
RowCount = RowCount + 1
End If
next sht
End Sub
 

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