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: 586
Default Data Not Transferring From Source to Data Worksheet

I have two worksheets: Source Worksheet is Sheets("New Data") and Global
Worksheet is Sheets("Global Schedule"). The macro below scans down "New
Data" Col.A and trys to find the sales order number in "Global Schedule"
Col.A. If the sales order # is not in "Global Schedule" it copies the data
from "New Data" to "Global Schedule"

This is my problem. For some reason when the macro trys to find sales order
# "19839-1" in "Global Schedule" it finds and returns "19839-10", why? Yes
"19839-10" is there, but it is not "19839-1", thus "19839-1" does not copy
from "New Data" to "Global Schedule". Any ideas?

Private Sub CopyNewItemsToGlobal()

SubName = "CopyNewItemsToGlobal"

Dim lngLastRow As Long
Dim rngNewData As Range
Dim rngGlobalRange As Range
Dim lngInsertRow As Long
Dim cell As Range
Dim rngFoundData As Range

' set Crystal data to find
With Sheets("New Data")
lngLastRow = .Cells(Rows.Count, "A").End(xlUp).Row
Set rngNewData = .Range("A1:A" & lngLastRow)
End With

With Sheets("Global Schedule")
lngLastRow = .Cells(Rows.Count, "A").End(xlUp).Row
Set rngGlobalRange = .Range("A3:A" & lngLastRow)
.Activate
.Unprotect "AdTech"
End With

' insertion row is the last row of global schedule
lngInsertRow = lngLastRow + 1

With Application
.ScreenUpdating = True
.StatusBar = "Finding New Data and Applying to Schedule...Please Wait"
.Cursor = xlNorthwestArrow
End With

' select lastrow so user can see items importing into schedule
Sheets("Global Schedule").Cells(lngLastRow, "A").Select

' copy data from new data sheet to global schedule sheet
For Each cell In rngNewData
Set rngFoundData = rngGlobalRange.Find(What:=cell.Text,
LookIn:=xlValues)

' if crystal data is not in global and isn't red, copy new data to
global
If rngFoundData Is Nothing And cell.Font.ColorIndex < 3 Then

' copy new data to global
Sheets("Global Schedule").Range("A" & lngInsertRow & ":Q" &
lngInsertRow).Value = _
Sheets("New Data").Range("A" & cell.Row & ":Q" &
cell.Row).Value

' reset the global range because you added a line to it
Set rngGlobalRange = Sheets("Global Schedule").Range("A3:A" &
lngInsertRow)
lngInsertRow = lngInsertRow + 1

End If
Next cell

End Sub

--
Cheers,
Ryan
 
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
Transferring CERTAIN Data from one worksheet to another Samantha Excel Worksheet Functions 1 May 7th 09 10:54 PM
Transferring data from one worksheet to another Amedea_C Excel Discussion (Misc queries) 0 August 12th 08 02:16 PM
Transferring chart data from one worksheet to another DaddyO Charts and Charting in Excel 1 April 27th 07 01:13 PM
Transferring data from one worksheet or workbook to another Janine Excel Worksheet Functions 5 September 5th 06 05:15 PM
Transferring Data from a UserForm to a worksheet Kezza Excel Programming 1 August 23rd 06 03:39 PM


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