Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Using a cell reference to select a worksheet within a macro

Unfortunately that is not working. Below is the current basic macro which
needs amending.

Again, AC8 is the location of the team as detailed in the previous post. I
need to be able for this to happen automatically every time a new line of
data is entered.

Range("AA2:AE2").Select
Selection.Copy
Sheets("Office Overview").Select - this is what i want to change so
"Office Overview" is Team 1,2,3 or 4 depending on the value of AC8
Rows("2:2").Select
Selection.Insert Shift:=xlDown
Selection.Font.ColorIndex = 0
Selection.Interior.ColorIndex = 0
Sheets("Entry").Select
Range("AA2:AE2").Select
Range("AE2").Activate
Selection.ClearContents
Range("A1").Select
ActiveWorkbook.Save
ActiveWorkbook.SaveCopyAs ("Objectives 2005 6 backup.xls")
UserForm1.Show

Regards

Richard

"Bernie Deitrick" wrote:

Richard,

Run the macro below.

HTH,
Bernie
MS Excel MVP



Sub ExportDatabaseToSeparateSheets()
'Export is based on the value in the desired column
Dim myCell As Range
Dim mySht As Worksheet
Dim myName As String
Dim myArea As Range
Dim myShtName As String
Dim KeyCol As Integer

myShtName = ActiveSheet.Name
KeyCol = InputBox("What column # within database to use as key?")


Set myArea = ActiveCell.CurrentRegion.Columns(KeyCol).Offset(1, 0).Cells

Set myArea = myArea.Resize(myArea.Rows.Count - 1, 1)

For Each myCell In myArea
On Error GoTo NoSheet
myName = Worksheets(myCell.Value).Name
GoTo SheetExists:
NoSheet:
Set mySht = Worksheets.Add(Befo=Worksheets(1))
mySht.Name = myCell.Value
With myCell.CurrentRegion
.AutoFilter Field:=KeyCol, Criteria1:=myCell.Value
.SpecialCells(xlCellTypeVisible).Copy _
mySht.Range("A1")
mySht.Cells.EntireColumn.AutoFit
.AutoFilter
End With
Resume
SheetExists:
Next myCell

End Sub


"Richard L" <Richard wrote in message
...
I hope this makes sense!!

I have a spreadsheet for data collection. This has 4 teams (1,2,3 and 4)
which currently gets merged onto 1 huge spreadsheet. I want to be able to
run a macro which splits the data onto 4 separate sheets.

Team 1
Team 2
Team 3
Team 4

I have tried using Sheets(AC8).Select - did not work. AC8 being the cell
referred to from the drop down box where the team number is selected.

Any ideas?

Regards

Richard




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using cell as worksheet reference (macro) Edwin Excel Discussion (Misc queries) 2 January 26th 10 08:42 PM
Reference another Worksheet and Conditionally Select Data Tina Hane Excel Worksheet Functions 3 March 12th 08 10:57 PM
Macro to Create New Worksheet and Reference Cell in Old Worksheet As Tab Name - "Object Required" Error [email protected] Excel Discussion (Misc queries) 4 September 25th 06 01:35 PM
select worksheet to run macro Hidaya Excel Discussion (Misc queries) 5 December 1st 04 11:54 PM
Help Please! Macro Error on Select Worksheet Apressler Excel Programming 1 September 23rd 04 04:58 PM


All times are GMT +1. The time now is 01:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"