PC Review


Reply
Thread Tools Rate Thread

code back to worksheet

 
 
project manager
Guest
Posts: n/a
 
      1st May 2009
I have written some code which goes through a series of worksheets which are
all the same except the name is different peoples intials. The code opens
each sheet and highlights the errors, I am trying to copy these errors into a
summary/report sheet. The code goes through each row and when it finds an
error jumps into the copying sub.

I have got the code copying the errors into a report template sheet but
can't get the code to jump back into the previously active worksheet, where
the data/errors have been copied from to carry on looking for more errors and
go through other sheets.

once it finds an error... (i know there's errors in the code only rough/
quick)

Range("A" & i : "L" & i).select
Copy.selecction
Call report

sheets("summary").select
-code to find the last row-
paste.selection
-now go back to last active sheet???-

Any help?
 
Reply With Quote
 
 
 
 
project manager
Guest
Posts: n/a
 
      1st May 2009
not too sure i get this, could you put a couple of notes to show what it does
at the major sections?

thanks

"Don Guillett" wrote:

> You should ALWAYS post your code for comments but you may like this idea.
>
> Sub foreachwsinarray()
> myarray = Array("sheet2", "sheet3")
> For Each sh In myarray
>
> For Each c In Sheets(sh).Range("a2:a22")
>
> With Sheets("sheet1")
>
> If c <> 1 Then
> lr = .Cells(Rows.Count, 1).End(xlUp).Row + 1
> c.EntireRow.Copy .Cells(lr, 1)
> End If
>
> End With
> Next c
>
> Next sh
> End Sub
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "project manager" <(E-Mail Removed)> wrote in
> message news:A3995040-6C50-4956-B2A0-(E-Mail Removed)...
> >I have written some code which goes through a series of worksheets which
> >are
> > all the same except the name is different peoples intials. The code opens
> > each sheet and highlights the errors, I am trying to copy these errors
> > into a
> > summary/report sheet. The code goes through each row and when it finds an
> > error jumps into the copying sub.
> >
> > I have got the code copying the errors into a report template sheet but
> > can't get the code to jump back into the previously active worksheet,
> > where
> > the data/errors have been copied from to carry on looking for more errors
> > and
> > go through other sheets.
> >
> > once it finds an error... (i know there's errors in the code only rough/
> > quick)
> >
> > Range("A" & i : "L" & i).select
> > Copy.selecction
> > Call report
> >
> > sheets("summary").select
> > -code to find the last row-
> > paste.selection
> > -now go back to last active sheet???-
> >
> > Any help?

>
>

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      1st May 2009

It is looking at each sheet you named in the array
it is looking down col a for any value not equal to 1
When found those values are copied to the next available row in sheet1
Try it

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"project manager" <(E-Mail Removed)> wrote in
message news:03779F44-1CAA-4636-825A-(E-Mail Removed)...
> not too sure i get this, could you put a couple of notes to show what it
> does
> at the major sections?
>
> thanks
>
> "Don Guillett" wrote:
>
>> You should ALWAYS post your code for comments but you may like this idea.
>>
>> Sub foreachwsinarray()
>> myarray = Array("sheet2", "sheet3")
>> For Each sh In myarray
>>
>> For Each c In Sheets(sh).Range("a2:a22")
>>
>> With Sheets("sheet1")
>>
>> If c <> 1 Then
>> lr = .Cells(Rows.Count, 1).End(xlUp).Row + 1
>> c.EntireRow.Copy .Cells(lr, 1)
>> End If
>>
>> End With
>> Next c
>>
>> Next sh
>> End Sub
>>
>> --
>> Don Guillett
>> Microsoft MVP Excel
>> SalesAid Software
>> (E-Mail Removed)
>> "project manager" <(E-Mail Removed)> wrote in
>> message news:A3995040-6C50-4956-B2A0-(E-Mail Removed)...
>> >I have written some code which goes through a series of worksheets which
>> >are
>> > all the same except the name is different peoples intials. The code
>> > opens
>> > each sheet and highlights the errors, I am trying to copy these errors
>> > into a
>> > summary/report sheet. The code goes through each row and when it finds
>> > an
>> > error jumps into the copying sub.
>> >
>> > I have got the code copying the errors into a report template sheet but
>> > can't get the code to jump back into the previously active worksheet,
>> > where
>> > the data/errors have been copied from to carry on looking for more
>> > errors
>> > and
>> > go through other sheets.
>> >
>> > once it finds an error... (i know there's errors in the code only
>> > rough/
>> > quick)
>> >
>> > Range("A" & i : "L" & i).select
>> > Copy.selecction
>> > Call report
>> >
>> > sheets("summary").select
>> > -code to find the last row-
>> > paste.selection
>> > -now go back to last active sheet???-
>> >
>> > Any help?

>>
>>


 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      2nd May 2009
Use a separate procedure to write the summary and pass the activesheet as an
argument like shown below...I have used your code only...Please try and
feedback

Sub <YourProcedure>
' check
Range("A" & i : "L" & i).select
Copy.selecction
Call WriteSummary(ActiveSheet)
'continue
End Sub


Sub WriteSummary(wsTemp as Worksheet)
'Procedure to write to summary. Source sheet passed as argument
Sheets("summary").select
-code to find the last row-
Paste.selection
-now go back to last active sheet???-
wsTemp.Activate
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"project manager" wrote:

> I have written some code which goes through a series of worksheets which are
> all the same except the name is different peoples intials. The code opens
> each sheet and highlights the errors, I am trying to copy these errors into a
> summary/report sheet. The code goes through each row and when it finds an
> error jumps into the copying sub.
>
> I have got the code copying the errors into a report template sheet but
> can't get the code to jump back into the previously active worksheet, where
> the data/errors have been copied from to carry on looking for more errors and
> go through other sheets.
>
> once it finds an error... (i know there's errors in the code only rough/
> quick)
>
> Range("A" & i : "L" & i).select
> Copy.selecction
> Call report
>
> sheets("summary").select
> -code to find the last row-
> paste.selection
> -now go back to last active sheet???-
>
> Any help?

 
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
Re: code back to worksheet Don Guillett Microsoft Excel Programming 0 1st May 2009 09:12 PM
Print worksheet 2 on back of worksheet 1, etc.... Lenny Microsoft Excel Misc 1 13th Feb 2009 11:07 PM
How to go back from 350 worksheet to the first worksheet in 1 file =?Utf-8?B?V2lsbW9zTGVl?= Microsoft Excel Misc 4 19th Jul 2004 01:00 AM
Copy Add-In Worksheet to Client Worksheet EXCLUDING VBA Code Mark D'Agosta Microsoft Excel Programming 1 8th Mar 2004 04:28 PM
Worksheet.Calculate code no longer executes on worksheet launch? Arris Microsoft Excel Worksheet Functions 1 28th Jan 2004 02:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:13 PM.