Macro finding and copying cells based on other cells

Ore_Ele

New Member
Joined
Jul 27, 2011
Messages
5
I have a spread sheet with 31 worksheets on it (30 baseball teams, and the 1 to simulate baseball games). I think I have the steps down that I need, but I just have no idea how to turn them into VB code for a Macro

What I'd like it to do is the following (this is just the first half, of finding the data and gathering it).

1) If cell Sheet1!A9 is empty, end macro.
2) Locate the worksheet that has the same name as cell Sheet1!A9 (in this cell, I place the team name, so if it is "SEA", it should go to the worksheet named "SEA", this way I can change it later to any team and the macro can still function)
3) Locate the cell in that worksheet that has the same name as cell Sheet1!B9 (in this cell, I place the batter name, this will always be in the A column).
4) Copy cells Bx:Dx (where x is the number that relates to step 3, so if step 3 finds us cell A17, we copy B17:D17, if step 3 finds A31, we copy B31:D31).
5) Paste into range Sheet1!B1:D1
6) (step 6 - 9 are going to be similar as 2 - 5, but this is for pitcher info). Locate worksheet that has the same name as Sheet1!C9.
7) Locate cell within that worksheet that has the same name as cell Sheet1!D9 (this will also be in the A column, as in the team worksheets, pitchers are below the batters, not off to the side).
8) Copy Bx:Dx
9) Paste into range Sheet1!B2:D2

10) (these will actually be the last steps, but I'd like to be able to test them) Delete row Sheet1!9.
11) repeat marco (until step 1 makes us stop).

If anyone knows the coding for any part of this (like just step 1), that would be of great help.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
I think I might have figured out most of this, by using the record macro (so it records actions rather than me having to manually type code), and using "ctrt-f" and the arrow keys.

But there is something that I can't figure out. Is there a way to do a search of the entire workbook EXCEPT for sheet1? Or to setup an area to be excluded from a search?
 
Upvote 0
Nope, didn't work. It didn't record the key strokes, but the actual cells that were copied. So I'm drawing a complete blank.
 
Upvote 0

Forum statistics

Threads
1,215,364
Messages
6,124,510
Members
449,166
Latest member
hokjock

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