LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Calling Specific sheet in workbook with Code

You reference three worksheets below (GESA CARD MATCHES, All Records,
and the ActiveSheet). I ran your code and it worked. What part are
you wanting to repeat for all sheets? What part are you saying is only
working for the "first" worksheet (and by "first", do you mean the
ActiveSheet)?

Mark


JOUIOUI wrote:
I have a dozen sheets in my workbook and I have one macro to format these
sheets. I've got the code I need for each sheet but when I run the macro, it
runs all the code on the first sheet in the workbook, not on the sheet
specified. For instance, in the code below, I'm wanting this to run on the
sheet titled "GESA CARD MATCHES", however it is not, it is running on the
first sheet in the workbook. Any idea what I'm doing wrong? Thanks



Sub GESACardMatches()

' Create GESA Credit Card REport with Just GESA Card items

Dim rng As Range, cell As Range

Dim i As Long, sh As Worksheet
With Worksheets("All Records")
Set rng = .Range(.Cells(1, 1), _
.Cells(Rows.Count, 1).End(xlUp))
End With
i = 1

Set sh = Worksheets("GESA CARD MATCHES")
For Each cell In rng
If UCase(Trim(cell.Value)) = "4-$" Or _
UCase(Trim(cell.Value)) = "CNO-$" Then
If UCase(Trim(cell.Offset(0, 1).Value)) = _
"GESA CC" Then
cell.EntireRow.Copy sh.Cells(i, 1)
i = i + 1

End If

End If

Next

With ActiveSheet

xLastrow = .Cells(.Rows.Count, 1).End(xlUp).Row

.Cells(xLastrow + 2, 5) = "Total"
.Cells(xLastrow + 2, 5).Font.Bold = True
.Cells(xLastrow + 2, 6).Formula = "=sum(F2:F" & xLastrow & ")"
.Cells(xLastrow + 2, 6).Font.Bold = True


 
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
How to add formula calling up current workbook when sheet copied Smudge Excel Discussion (Misc queries) 6 September 7th 07 10:40 AM
Code for opening a workbook at a specific time!?! mike_vr Excel Discussion (Misc queries) 2 June 5th 07 04:55 PM
Calling a bit of code from a sheet errors gearoi Excel Discussion (Misc queries) 2 September 6th 05 08:21 PM
Reference code in another workbook from a calling workbook Datasort Excel Programming 1 January 4th 05 01:13 AM
Unable to Run Code on Specific workbook Renato Excel Programming 3 December 12th 04 06:17 PM


All times are GMT +1. The time now is 10:00 AM.

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"