Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default find and paste - help with code

Hello all, I have been trying to modify some code to do the following,
A B C D E E
0014166 0141 6771230 11 01 14-Feb-07
6771230 3614
6765118 2152 2753438 11 01 09-Apr-07
Sheet "Tool Tracking"


A B C D E F
6771230 97 ZEAFHZP VA37 Z013261 20070620
6774767 VG96 2734467 20070317

Sheet"LCS"


I need to compare the numbers in "A" on both sheets, if found on both
sheets, check "Tool Tracking" for value in "C", if nothing then check
"E" on "LCS" if there is a value then copy cell in "E" from sheet"LCS"
to "Tool Tracking" - The value "Z013261" in the example above must be
copied to "C" in sheet "Tool Tracking".

Some code would be greatly appreciated.

Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default find and paste - help with code

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim iLastRow As Long
Dim shLCS As Worksheet
Dim iRow As Long

Set shLCS = Worksheets("LCS")
With Worksheets("Tool Tracking")

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To iLastRow
iRow = 0
On Error Resume Next
iRow = Application.Match(.Cells(i, TEST_COLUMN),
shLCS.Columns(1), 0)
On Error GoTo 0
If iRow 0 Then
If .Cells(i, "C").Value = "" Then
.Cells(i, "C").Value = shLCS.Cells(iRow, "E").Value
End If
End If
Next i

End With

End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Les Stout" wrote in message
...
Hello all, I have been trying to modify some code to do the following,
A B C D E E
0014166 0141 6771230 11 01 14-Feb-07
6771230 3614
6765118 2152 2753438 11 01 09-Apr-07
Sheet "Tool Tracking"


A B C D E F
6771230 97 ZEAFHZP VA37 Z013261 20070620
6774767 VG96 2734467 20070317

Sheet"LCS"


I need to compare the numbers in "A" on both sheets, if found on both
sheets, check "Tool Tracking" for value in "C", if nothing then check
"E" on "LCS" if there is a value then copy cell in "E" from sheet"LCS"
to "Tool Tracking" - The value "Z013261" in the example above must be
copied to "C" in sheet "Tool Tracking".

Some code would be greatly appreciated.

Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default find and paste - help with code

Sub Fill_Column_C()
Dim shLCS As Worksheet, shTrk As Worksheet
Dim rLCS As Range, rTrk As Range
Dim r1 As Range, r2 As Range
Dim cell As Range, res As Variant
Set shLCS = Worksheets("LCS")
With shLCS
Set rLCS = .Range(.Cells(2, 1), .Cells(2, 1).End(xlDown))
End With

Set shTrk = Worksheets("Tool Tracking")
With shTrk
Set rTrk = .Range(.Cells(2, 1), .Cells(2, 1).End(xlDown))
End With

For Each cell In rTrk
If Len(Trim(cell.Offset(0, 2))) = 0 Then
res = Application.Match(cell.Value, rLCS, 0)
If Not IsError(res) Then
Set r1 = rLCS(res)
Set r2 = r1.Offset(0, 4)
If Len(Trim(r2)) < 0 Then
cell.Offset(0, 2).Value = r2
End If
End If
End If
Next

End Sub

--
Regards,
Tom Ogilvy


"Les Stout" wrote:

Hello all, I have been trying to modify some code to do the following,
A B C D E E
0014166 0141 6771230 11 01 14-Feb-07
6771230 3614
6765118 2152 2753438 11 01 09-Apr-07
Sheet "Tool Tracking"


A B C D E F
6771230 97 ZEAFHZP VA37 Z013261 20070620
6774767 VG96 2734467 20070317

Sheet"LCS"


I need to compare the numbers in "A" on both sheets, if found on both
sheets, check "Tool Tracking" for value in "C", if nothing then check
"E" on "LCS" if there is a value then copy cell in "E" from sheet"LCS"
to "Tool Tracking" - The value "Z013261" in the example above must be
copied to "C" in sheet "Tool Tracking".

Some code would be greatly appreciated.

Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default find and paste - help with code

Thank you so much Bob and Tom, as always i really appreciate your
help... Great day further, im off home it is 22:15 here... ;0)

Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default find and paste - help with code

Sorry Tom, just a further question, i am also using your code to copy
over a date in the format 20070223, but on the KTL sheet where it gets
copied to the cell format is set as "dd-mmm-yy" and when it copies it in
it just shows ################ is there a way around this ??

Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default find and paste - help with code

Make the column wider. If that doesn't work,
Look at the value stored in the cell. Format the cell as General.

What is in the Cell.

--
Regards,
Tom Ogilvy

"Les Stout" wrote:

Sorry Tom, just a further question, i am also using your code to copy
over a date in the format 20070223, but on the KTL sheet where it gets
copied to the cell format is set as "dd-mmm-yy" and when it copies it in
it just shows ################ is there a way around this ??

Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

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
Find a Unique code cut and paste kingie Excel Discussion (Misc queries) 0 November 11th 09 08:05 PM
Find/Copy/paste.. then Find/Paste - not working ... at all.... [email protected] Excel Programming 9 November 30th 06 08:49 PM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
code to FIND value, copy, paste values onto other sheet ufo_pilot Excel Programming 2 December 6th 05 04:14 PM


All times are GMT +1. The time now is 12:37 PM.

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"