Macro to insert value from range on different sheet and copy sheet

D

Diddy

Hi everyone,

I'm using C2 in "Summary" sheet as the lookup value for Index Match formulas
pulling data from "Data" sheet. the lookup array where the C2 is found is
A5:A67 (named range "LocCode" Location Code) on "Data".
"Summary" has a table of data and chart for each Location Code.
What I'd like to do now is have a macro that enters each Location Code from
A5:A67 one at a time and copy the sheet and rename tab with the relevant
Location Code so that I have 1 sheet per each location code.

If anyone can help me with this, it would make me happier than you can
imagine. I'm getting so muddled trying to do this one. Probably because I'm
really cheesed off with this job. It was done as a favour. We're really
snowed under and thought that the person who asked for it would be chuffed
with a dynamic workbook. Everyone seems to be in favour of electronic version
and being green when it's not their project! Our boss, who originally said we
were too busy just now,has now asked us to provide same data 1 sheet per
Location Code because the other department "isn't very computer savvy" and
they'd like to print it!!!! OMG!
Sorry!! Rant over.
Cheers
Diddy
 
D

Diddy

Hi Simon,

That's fantastic!!!

I've added some recorded code to copy and paste as values but suspect there
is a better way to do this.

Sub create_sheets()
Dim Rng As Range, MyCell As Range
Application.ScreenUpdating = False
Set Rng = Sheets("Data").Range("LocCode")
For Each MyCell In Rng
Sheets("Trends").Range("b2").Value = MyCell.Value
With Sheets("Trends")
..Copy Before:=Sheets(2)
Cells.Select
Range("B1").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
ActiveCell.FormulaR1C1 = "`"
ActiveSheet.Name = .Range("b2").Value
End With
Sheets("Trends").Select
Next
Application.ScreenUpdating = True
End Sub

THANK YOU so so much!!!
 

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