LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Help with Extending code (Comparing Two Sheets)

Hi there,

the code below does everything i need it too do, what it does is insert a
formula, the formula compares information on 2 sheets. Basically the 1st
formula compares what was on last week and not on this week, the second
formula does vise versa and the 3rd formula shows what parts were common to
both sheets.
What i do manually each week is copy and paste these formulas all the
way down to row 1000. then select range b2:h1000, data sort then delete any
blank spaces (remembering that these blanks actually have formulas in them),
i do the same with j2:o1000 and i do the same with q2:x1000.
I then copy and paste specialvalues all of the information from b2:h???
range (this varies every week as does each of the other ranges)
on to the end of range q2:x??????, i then copy all the information from
j2:o???? onto the end of q2:x????.

If someone could show me how to automate the above I would be very
thankfull.

Sub Insert_Formula()
Application.ScreenUpdating = False
ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("1103 Working Sheet Last Week").Select
Cells.Select
Selection.ClearContents
ActiveWindow.ScrollWorkbookTabs Sheets:=-1
ActiveWindow.ScrollWorkbookTabs Sheets:=-1
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("1103 NonAdhD Last Week").Select
Cells.Select
Selection.Copy
ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("1103 Working Sheet Last Week").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
Rows("1:36").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
Columns("A:D").Select
Selection.Delete Shift:=xlToLeft
Columns("B:H").Select
Selection.Delete Shift:=xlToLeft
Range("B1").Select
Application.Run "PERSONAL.XLS!SumAll"
Range("B1").Select
ActiveCell.FormulaR1C1 = "'Value"
Range("C2").Select
ActiveWindow.ScrollWorkbookTabs Sheets:=-1
Sheets("Compare Working Sheet").Select
Range("A1").Select
With ActiveSheet
.Range("B3").Formula _
= "=IF(COUNTIF('1103 Working Sheet Last Week'!A:A," _
& "'1103 Working Sheet'!A2)=0,'1103 Working
Sheet'!A2,"""")"
.Range("H3").Formula _
= "=VLOOKUP(B3,'1103 Working Sheet'!$A$2:$B$1500,2,FALSE)"
.Range("J3").Formula _
= "=IF(COUNTIF('1103 Working Sheet'!A:A," _
& "'1103 Working Sheet Last Week'!A2)=0,'1103 Working Sheet
Last Week'!A2,"""")"
.Range("O3").Formula _
= "=VLOOKUP(J3,'1103 Working Sheet Last
Week'!$A$2:$B$1500,2,FALSE)"
.Range("Q3").Formula _
= "=IF(COUNTIF('1103 Working Sheet'!A:A," _
& "'1103 Working Sheet Last Week'!A2)=1,'1103 Working Sheet
Last Week'!A2,"""")"
.Range("R3").Formula _
= "=IF(ISNA(VLOOKUP(Q3,'1103 NonAdhD This
Week'!$E$37:$F$1500,2,FALSE))," _
& "VLOOKUP(Q3,'1103 NonAdhD Last Week'!$E$37:$F$1500,2,FALSE),"
_
& "(VLOOKUP(Q3,'1103 NonAdhD Last
Week'!$E$37:$F$1500,2,FALSE)))"
.Range("S3").Formula _
= "=IF(ISNA(INDEX('1103 NonAdhD Last
Week'!$C$37:$E$1000,MATCH(Q3,'1103 NonAdhD Last Week'!$E$37:$E$1000,0),1)),"
_
& """"",(INDEX('1103 NonAdhD This
Week'!$C$37:$E$1000,MATCH(Q3,'1103 NonAdhD This Week'!$E$37:$E$1000,0),1)))"
.Range("U3").Formula _
= "=IF(ISNA(VLOOKUP(Q3,'1103 NonAdhD This
Week'!$E$37:$G$1000,3,FALSE)),"""",(VLOOKUP(Q3,'11 03 NonAdhD Last
Week'!$E$37:$G$1000,3,FALSE)))"
.Range("V3").Formula _
= "=VLOOKUP(Q3,'1103 Working Sheet Last
Week'!$A$1:$B$1000,2,FALSE)"
.Range("W3").Formula _
= "=VLOOKUP(Q3,'1103 Working Sheet'!$A$2:$B$1500,2,FALSE)"
.Range("X3").Formula _
= "=W3-V3"
Application.ScreenUpdating = True

End With
End Sub



thanks BigH


 
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
Comparing Two Sheets Pete Petersen Excel Worksheet Functions 2 April 7th 10 10:04 PM
Comparing 2 sheets PauloG Excel Discussion (Misc queries) 5 May 13th 08 12:47 PM
Comparing Across Sheets RJB Excel Discussion (Misc queries) 1 March 6th 08 02:23 AM
comparing 2 sheets rodchar Excel Discussion (Misc queries) 3 September 11th 07 03:55 AM
Event Procedure - Extending code TBD Excel Programming 2 September 29th 05 03:16 PM


All times are GMT +1. The time now is 08:45 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"