Hello Steve,
I've tried out the macro and it goes like this.Here the workbook wher
the datas are entered regularly is called "newdata" and the sheet i
called "NewStuff". This is where all the new datas are entered.
This workbook is to be updated to the workbook called "Managemen
Information System_2005" and the name of the sheet is "Raw Data". Ra
Data has around 46 Column Headers (Names, Codes, City, Date of Entry
Currency Amount etc) and about 3000 rows of informations consisting of
text, numbers, strings, alphanumbericals etc.
"NewStuff" sheet contains almost the same thing as "Raw Data". Ne
entries are entered here in this sheet and they are to be updated t
the Raw Data sheet at the end of the month.
I am still getting errors now. Can you please see where I am goin
wrong.
------------------------------------------------------
Sub CheckReplaceData()
' find number of rows in data workbook.
lrw1 = Workbooks("newdata").Sheets("NewStuff").Cells(Rows .Count
"A").End(xlUp).Row
'(NOTE: IN THE ABOVE CODE, I am getting a "Runtime Error 9, Subscrip
out of Range" Message)
' loop through NewStuff - assuming that New stuff starts on row 2 an
has 8
'columns of data
For rw1 = 2 To lrw1
If WorksheetFunction.CountIf(Workbooks("Management Informatio
System_2005").Sheets("Raw Data").Columns(1)
Workbooks("newdata").Sheets("NewStuff").Cells(rw1, 1)) = 0 Then
' your code to add a new line
Dim lrw As Long
' find last used row in Old data and add 1 to get next empty row
lrw = Workbooks("Management Information System_2005").Sheets("Ra
Data").Cells(Rows.Count, "A").End(xlUp).Row + 1
'Copy and paste new data to old stuff - copies entire row and paste
first
'cell in empty row
' you could alter the code to copy a range and paste it.
Workbooks("newdata").Sheets("NewStuff").Rows(rw1). Copy _
Destination:=Workbooks("Management Informatio
System_2005").Sheets("Raw Data").Range("A" & lrw)
Else: MacroCheckReplace
End If
Next
End Sub
-----------------------------------------------------------------------------
Sub MacroCheckReplace()
' row to check and change in OldStuff
rw2
WorksheetFunction.Match(Workbooks("newdata").Sheet s("NewStuff").Cells(rw1
1), Workbooks("Management Information System_2005").Sheets("Ra
Data").Columns(1), 0)
' loop each column
For col1 = 2 To 8
If Workbooks("newdata").Sheets("NewStuff").Cells(rw1, col1) < _
Workbooks("Management Information System_2005").Sheets("Ra
Data").Cells(rw2, col1) Then
Workbooks("Management Information System_2005").Sheets("Ra
Data").Cells(rw2, col1) = _
Workbooks("newdata").Sheets("NewStuff").Cells(rw1, col1)
Else ' put in other code if the cells are equal
End If
Next
End Sub
'Sub InsertRow()
'Dim Rng
'Rng = InputBox("Enter number of rows required.")
'Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(Rng - 1, 0)).Select
'Selection.EntireRow.Insert
'End Su
--
laltha
-----------------------------------------------------------------------
lalthan's Profile:
http://www.excelforum.com/member.php...fo&userid=1055
View this thread:
http://www.excelforum.com/showthread.php?threadid=39722