Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating copy/paste/check vb program for excel

Status
Not open for further replies.

evild

Technical User
Nov 25, 2002
71
GB
I am about to write a program to do the following:

I have two spreadsheets (sheet1 and sheet2) and I wish to copy data from sheet2 to sheet1 only if it does not already exist in sheet1.
[tt]
Open Sheet2
For each row in Sheet2
Check row has data;
Check row is not already present in Sheet1;
Amend Sheet1 with new data from current row
in sheet 2 at the next available row in Sheet1;
Enter default values in extra columns in Sheet1;
End Loop
Delete row data in Sheet1 where ‘status’ = …
[/tt]
Ideally I want to create a procedure for each of the statements but I don't know VB code and so I need some help with this. I thought I'd post here before I start in case anyone has any bright ideas they can suggest.
I am hoping this is quite a simple task to accomplish in VB?
 
Record a macro using some sample data and see what is produced, then use that as a basis for further development.

VBA is very easy to learn and you will pick it up very quickly with a little effort
 
I am more interested in the loop structure. I can record a macro and look at the script but I need help with the loops. Here, I want to cycle through every row and perform an operation. I also want to find the 'next empty row available' as one part of the program.
The copy and paste operations are quite simple but the rest I am not sure about.
 
Can somesome help me out. How do I loop through all rows of a spreadsheet?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top