PC Review


Reply
Thread Tools Rate Thread

Copy value from worksheets

 
 
farid2001
Guest
Posts: n/a
 
      30th Dec 2008
Dear gentlemen
I have about 250 worksheets in a workbook, each worksheet has customer name
which appears on cell "F2" of each worksheet, what I need is to be able to
make a summary in a new worksheet in such a way that in cell "A2" I would get
"F2" of first customer and in cell "B2" I would get cell "J3" of that
customer.
Then on cell "A3" I would get "F2" of second worksheet and in "B3" I would
get "J3" of second worksheet.
Then on cell "A4" get "F2" of third wksheet and "J3" of third wksheet and so
on.

Your help will be grearly appreciated.
thanks & regards
farid2001
 
Reply With Quote
 
 
 
 
Mike
Guest
Posts: n/a
 
      30th Dec 2008
Maybe something like this
Sub testing()
Const SumSheetName = "Sheet1"
Dim sumWS As Worksheet
Dim ws As Worksheet
Dim i As Long
i = 1
Set sumWS = Worksheets(SumSheetName)
For Each ws In Worksheets
If ws.Name <> sumWS.Name Then
sumWS.Range("A" & i) = ws.Range("F2")
sumWS.Range("B" & i) = ws.Range("J2")
i = i + 1
End If
Next ws
End Sub

"farid2001" wrote:

> Dear gentlemen
> I have about 250 worksheets in a workbook, each worksheet has customer name
> which appears on cell "F2" of each worksheet, what I need is to be able to
> make a summary in a new worksheet in such a way that in cell "A2" I would get
> "F2" of first customer and in cell "B2" I would get cell "J3" of that
> customer.
> Then on cell "A3" I would get "F2" of second worksheet and in "B3" I would
> get "J3" of second worksheet.
> Then on cell "A4" get "F2" of third wksheet and "J3" of third wksheet and so
> on.
>
> Your help will be grearly appreciated.
> thanks & regards
> farid2001

 
Reply With Quote
 
farid2001
Guest
Posts: n/a
 
      30th Dec 2008
Thanks guys, but I get error message "Subindex out of interval"
What could be wrong?

Regards
farid2001

"mikeaj72" wrote:

>
> Code:
> --------------------
> Sub testing()
> Const SumSheetName = "Sheet1"
> Dim sumWS As Worksheet
> Dim ws As Worksheet
> Dim i As Long
> i = 1
> Set sumWS = Worksheets(SumSheetName)
> For Each ws In Worksheets
> If ws.Name <> sumWS.Name Then
> sumWS.Range("A" & i) = ws.Range("F2")
> sumWS.Range("B" & i) = ws.Range("J2")
> i = i + 1
> End If
> Next ws
> End Sub
> --------------------
>
>
> --
> mikeaj72
> ------------------------------------------------------------------------
> mikeaj72's Profile: http://www.thecodecage.com/forumz/member.php?userid=46
> View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=44996
>
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      30th Dec 2008
Either make sure you have a worksheet named Sheet1 when you start the macro.

Or change this line:
Const SumSheetName = "Sheet1"
to show the name of the sheet that acts as a summary sheet.

If that's not the line that causes the error, then you'll have to share more
information.

farid2001 wrote:
>
> Thanks guys, but I get error message "Subindex out of interval"
> What could be wrong?
>
> Regards
> farid2001
>
> "mikeaj72" wrote:
>
> >
> > Code:
> > --------------------
> > Sub testing()
> > Const SumSheetName = "Sheet1"
> > Dim sumWS As Worksheet
> > Dim ws As Worksheet
> > Dim i As Long
> > i = 1
> > Set sumWS = Worksheets(SumSheetName)
> > For Each ws In Worksheets
> > If ws.Name <> sumWS.Name Then
> > sumWS.Range("A" & i) = ws.Range("F2")
> > sumWS.Range("B" & i) = ws.Range("J2")
> > i = i + 1
> > End If
> > Next ws
> > End Sub
> > --------------------
> >
> >
> > --
> > mikeaj72
> > ------------------------------------------------------------------------
> > mikeaj72's Profile: http://www.thecodecage.com/forumz/member.php?userid=46
> > View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=44996
> >
> >


--

Dave Peterson
 
Reply With Quote
 
farid2001
Guest
Posts: n/a
 
      30th Dec 2008
Thanks Dave

That was the problem, it works great now.

Regards
farid2001

"Dave Peterson" wrote:

> Either make sure you have a worksheet named Sheet1 when you start the macro.
>
> Or change this line:
> Const SumSheetName = "Sheet1"
> to show the name of the sheet that acts as a summary sheet.
>
> If that's not the line that causes the error, then you'll have to share more
> information.
>
> farid2001 wrote:
> >
> > Thanks guys, but I get error message "Subindex out of interval"
> > What could be wrong?
> >
> > Regards
> > farid2001
> >
> > "mikeaj72" wrote:
> >
> > >
> > > Code:
> > > --------------------
> > > Sub testing()
> > > Const SumSheetName = "Sheet1"
> > > Dim sumWS As Worksheet
> > > Dim ws As Worksheet
> > > Dim i As Long
> > > i = 1
> > > Set sumWS = Worksheets(SumSheetName)
> > > For Each ws In Worksheets
> > > If ws.Name <> sumWS.Name Then
> > > sumWS.Range("A" & i) = ws.Range("F2")
> > > sumWS.Range("B" & i) = ws.Range("J2")
> > > i = i + 1
> > > End If
> > > Next ws
> > > End Sub
> > > --------------------
> > >
> > >
> > > --
> > > mikeaj72
> > > ------------------------------------------------------------------------
> > > mikeaj72's Profile: http://www.thecodecage.com/forumz/member.php?userid=46
> > > View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=44996
> > >
> > >

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy worksheets =?Utf-8?B?ZXhjZWwtdHI=?= Microsoft Excel Programming 6 2nd Apr 2007 04:14 PM
how do i copy a cell in worksheets 10 to the other 9 worksheets =?Utf-8?B?YmV0ZQ==?= Microsoft Excel New Users 3 15th Mar 2007 10:41 AM
Copy data from multiple worksheets to worksheets in a number of other spreadsheets SteveH Microsoft Excel Discussion 5 6th Nov 2006 06:59 PM
Copy to different worksheets on next row =?Utf-8?B?Qm9i?= Microsoft Excel Programming 0 11th Oct 2006 08:14 AM
copy between worksheets does not copy formulae just values =?Utf-8?B?Q2hyaXNAMTAwMCBPYWtz?= Microsoft Excel Misc 0 19th Mar 2006 11:44 AM


Features
 

Advertising
 

Newsgroups
 


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