LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Help needed with Complicated code (For me !!)

Hi all, i have the code below which i got off a site. I have changed it to
suit me but i need help with the second part.. I have put comments in the
code below.

Sub Test2()
'
Dim todaysDateLong As String
Dim sh1 As Worksheet, sh2 As Worksheet, sh3 As Worksheet
Dim sh4 As Worksheet, sh5 As Worksheet, sh6 As Worksheet
Dim rng1 As Range, rng2 As Range
Dim rng3 As Range, rng4 As Range
Dim rw As Long, cell As Range

ActiveWorkbook.Worksheets("PU0703LCS").Rows("1:1") .Copy
ActiveWorkbook.Worksheets.Add(Befo=ActiveSheet) .Name = "LCS_KTL AI
Diff"
ActiveSheet.Paste

Set sh1 = Worksheets("PU0703LCS")
Set sh2 = Worksheets("KTL")
rw = 2
Set rng1 = sh1.Range(sh1.Cells(2, 1), sh1.Cells(2, 1).End(xlDown))
Set rng2 = sh2.Range(sh2.Cells(2, 1), sh2.Cells(2, 1).End(xlDown))
For Each cell In rng1
If Application.CountIf(rng2, cell.Value) = 0 Then

Else
Set sh4 = Worksheets("PU0703LCS")
Set sh5 = Worksheets("KTL")
Set sh6 = Worksheets("LCS_KTL AI Diff")
Set rng3 = sh4.Range(sh4.Cells(2, 2), sh4.Cells(2, 2).End(xlDown))

'--I need to know if the cell above (2) if it is higher than cell (10) below

Set rng4 = sh2.Range(sh5.Cells(2, 10), sh5.Cells(2, 10).End(xlDown))

'-- If yes then copy and paste into sh6

If Application.CountIf(rng4, cell.Value) = 0 Then
cell.EntireRow.Copy sh6.Cells(rw, 1)
rw = rw + 1
End If

End If
Next

Range("A1").Select
Columns("A:O").EntireColumn.AutoFit
End Sub

--
Les
 
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
Complicated lookup/match formula help needed! Jason[_11_] Excel Worksheet Functions 2 March 21st 08 12:39 AM
Complicated formula help needed please Alex H[_2_] Excel Worksheet Functions 2 September 6th 07 03:17 PM
A rather complicated Macro needed. Matt[_35_] Excel Programming 2 February 10th 06 08:03 PM
Complicated macro needed (please) Kjell[_3_] Excel Programming 3 October 19th 04 02:56 AM


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