Thread: Lost in code
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Jim May Jim May is offline
external usenet poster
 
Posts: 477
Default Lost in code

thanks excelent,
Great code!
Jim

"excelent" wrote:

Hi Jim
Here is another example
Im sure that Dave's code works fine.
just trying to show there is many way's to do the same job
Remember u dont have to Select/Activate a Sheet to copy from it
(it slow's your code)
good luck and go for it :-)

Sub Sumary()

Dim myCell As String
Dim ws As Integer

On Error GoTo wsAdd
Sheets("Summary").Select
myCell = Application.InputBox("Cells to copy ?", Type:=8).Address

For ws = 1 To Sheets.Count - 1
Cells(ws, 1) = Sheets(ws).Name
Cells(ws, 2) = Sheets(ws).Range(myCell)
Next

GoTo finish
wsAdd:
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "Summary"
On Error GoTo 0
Resume Next
finish:
End Sub



"Jim May" skrev:

I'm trying to creat a macro which will copy and paste the value of a cell
(say G12 on a series of worksheets) to a newly created sheet "Summary". The
code (so far) is below, but far short of what I want to acheive. Can someone
help me?


Sub GetMyCellValues()
Dim ws As Worksheet
Dim myCell As String
i = 1
myCell = Application.InputBox("Enter Cell Reference")
Sheets.Add
ActiveSheet.Name = "Summary"
For Each ws In Worksheets
Worksheets(ws.Name).Select
'Worksheets(ws.Name).Range("a4").Select
Worksheets(ws.Name).Range(myCell).Copy _
Destination:=Worksheets("Summary").Cells(i, 2)
Worksheets("Summary").Cells(i, 1) = ws.Name
i = i + 1
Next ws
End Sub