Solved

Need macro to insert data across sheets and workbooks

Posted on 2011-03-10
2
228 Views
Last Modified: 2012-05-11
In Excel 2003, I have a sheet where I keep track of conference room schedules. I need to add another room to the list. I have 4 workbooks, one for each quarter of the year. The rooms need to be listed in a particular order and with specific spacing. I need to add 6 Main to each worksheet in each workbook, and it must appear 6 cells below the listing for 17 North. So on the April sheet that is attached, 6 Main will appear in cells A32, A70, etc.

And I would need to copy this pattern to each worksheet in the workbook, and to the other quarterly worksheets/workbooks for the rest of this year.
Conference-Room-Schedule.xls
0
Comment
Question by:contrain
2 Comments
 
LVL 23

Accepted Solution

by:
redrumkev earned 500 total points
ID: 35104083
contrain,

How are you doing?

Try the following:

You can change the string variables to update for "new/other rooms". I wasn't sure if you would have the (number) below "6 Main"? If you need this, then change the numbers 1234, which are within '(1234) to the number you want to use.
If this is not needed, comment out the variable NewNumber and the second cell.offset line.

Note - your spacing is off, the first 17 North has only 3 lines "17 North, (4119), and a blank row", while the rest of them have 4 lines such as: " 17 North, (4119), blank row one, blank row two".

Excel file attached as well.

Hope this helps,
Kevin

Sub AddConferenceRoom()

Dim ws As Worksheet
Dim cell, rng As Range
Dim LastRoom, NewRoom, NewNumber As String

    Application.ScreenUpdating = False

        Set rng = [A1:A5000]
        LastRoom = "17 North "
        NewRoom = "6 Main"
        NewNumber = "'(1234)"
        
            For Each cell In rng
                If cell = LastRoom Then
                    cell.Offset(7, 0).Value = NewRoom
                    cell.Offset(8, 0).Value = NewNumber
                    Else
                End If
            Next cell
                
    Application.ScreenUpdating = False
        
End Sub

Open in new window

Conference-Room-Schedule-version.xls
0
 

Author Closing Comment

by:contrain
ID: 35111242
Absolutely Perfect! This is exactly what I wanted and it does just what I need it to do. And the explanation was very clear and understandable, and the returned sheet with the code already in there made my life a whole lot easier. Thank you sage redrumkev!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question