View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
STEVE BELL STEVE BELL is offline
external usenet poster
 
Posts: 692
Default Updating a database with macro

Lathan,

Your errors most likey come from excel not recognizing the workbook and
worksheet names.
And possibly not seeing some multiple lines as single lines.

If you make sure that Option Explicit are at the top of your modules - Excel
will help you find potential
problems with your code.

Also - it helps to tell us what error code/message you are getting.

1st make sure that this appears as a single line in the code. (Note the
line continuation " _" )
2nd replace wkbk1 and NewStuff with the corresponding names of the data
workbook.
And you still have wkbk2 and OldStuff that need replacing.

If WorksheetFunction.Countif(Workbooks("Management Information
System_2005").Sheets("Raw Data").Columns(1), _
Workbooks("wkbk1").Sheets("NewStuff").Cells(rw1,1) )= 0 Then
rw2
=worksheetfunction.Match(Workbooks("wkbk1").Sheets ("NewStuff").Cells(rw1,1),_Workbooks("wkbk2").Shee ts("OldStuff").Columns(1),0)
End If

To add a new line to OldStuff:

Dim lrw as Long

' find last used row in Old data and add 1 to get next empty row
lrw = Workbooks("wkbk2").Sheets("OldStuff").Cells(Rows.C OUNT,
"A").End(xlUp).Row +1

' Copy and paste new data to old stuff - copies entire row and pastes first
cell in empty row
' you could alter the code to copy a range and paste it.
Workbooks("wkbk1").Sheets("NewStuff").Rows(rw1).Co py _
Destination:= Workbooks("wkbk2").Sheets("OldStuff").Range("A" & lrw)

--
steveB

Remove "AYN" from email to respond
"lalthan" wrote in
message ...

Hello,
I've tried the code. I have replaced the workbook name (master data)
and sheet name and I am getting an error with the following two codes
below:

1.If WorksheetFunction.Countif(Workbooks("Management Information
System_2005").Sheets("Raw Data").Columns(1),
_Workbooks("wkbk1").Sheets("NewStuff").Cells(rw1,1 ))= 0 Then

2.rw2
=worksheetfunction.Match(Workbooks("wkbk1").Sheets ("NewStuff").Cells(rw1,1),_Workbooks("wkbk2").Shee ts("OldStuff").Columns(1),0)


Also, if a new entry in the new data is missing in the master file,
what should be the correct code that I should use to add a new line in
the master file and put all the values in the new line


--
lalthan
------------------------------------------------------------------------
lalthan's Profile:
http://www.excelforum.com/member.php...o&userid=10557
View this thread: http://www.excelforum.com/showthread...hreadid=397222