Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Please correct for me this code


Hi guys

-I would like to compare to columns (A, S) ,
for exemple A2 with the hole of S until the lastrow
-and if for exemple A2 = S10, then I like to put all the row (M10, N10
O10, P 10, Q 10 and R10) in another coloumn X2.
This the code I did but it doesnot work please coreect ift for me i
you could (please stay simple because I am new in Macros)

Sub comparetwocoloumns()
'
'
Dim rng As Range, i As Long, LastRow As Long, res As Variant
Range("S2").Select
LastRow = Selection.End(xlDown).Select
Application.WindowState = xlMinimized
Application.WindowState = xlNormal
For i = 2 To LastRow
res = Application.Match("A & i : A & LastRow", "S & i", 0)
If Not IsError(res) Then
Cells("X & i").Value = _
Cells("M & i: R & i").Value
End If
Next i
End Sub

many thanks for the hel

--
Freeman_10
-----------------------------------------------------------------------
Freeman_100's Profile: http://www.excelforum.com/member.php...fo&userid=3320
View this thread: http://www.excelforum.com/showthread.php?threadid=53202

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Please correct for me this code

Try this:

Sub comparetwocoloumns()
'
'
Dim rng As Range, i As Long, LastRow As Long, res As Variant

LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Application.WindowState = xlMinimized
Application.WindowState = xlNormal
For i = 2 To LastRow
res = Application.Match(Cells(i, "A"), Range("S:S"), 0)
If Not IsError(res) Then
Cells(res, "M").Resize(1, 6).Copy Cells(i, "X")
End If
Next i
End Sub

"Freeman_100" wrote:


Hi guys

-I would like to compare to columns (A, S) ,
for exemple A2 with the hole of S until the lastrow
-and if for exemple A2 = S10, then I like to put all the row (M10, N10,
O10, P 10, Q 10 and R10) in another coloumn X2.
This the code I did but it doesnot work please coreect ift for me if
you could (please stay simple because I am new in Macros)

Sub comparetwocoloumns()
'
'
Dim rng As Range, i As Long, LastRow As Long, res As Variant
Range("S2").Select
LastRow = Selection.End(xlDown).Select
Application.WindowState = xlMinimized
Application.WindowState = xlNormal
For i = 2 To LastRow
res = Application.Match("A & i : A & LastRow", "S & i", 0)
If Not IsError(res) Then
Cells("X & i").Value = _
Cells("M & i: R & i").Value
End If
Next i
End Sub

many thanks for the help


--
Freeman_100
------------------------------------------------------------------------
Freeman_100's Profile: http://www.excelforum.com/member.php...o&userid=33208
View this thread: http://www.excelforum.com/showthread...hreadid=532024


Reply
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
#Value! error on code that should be correct? RHein Excel Discussion (Misc queries) 2 January 3rd 08 03:19 AM
Please Help Correct my code saziz[_39_] Excel Programming 16 December 16th 05 01:24 AM
is this vba code correct or is there a more simple way to do this ? Jean-Pierre D via OfficeKB.com Excel Programming 9 August 12th 05 05:13 PM
Code is not correct Pat Excel Programming 10 April 6th 05 02:03 AM
Help to correct code Pat Excel Programming 6 December 29th 04 05:02 PM


All times are GMT +1. The time now is 07:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"