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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fill the empty cells of one xl sheet by referencing another xl sheet

Status
Not open for further replies.

innoc

MIS
Dec 3, 2001
2
JP
Hello all,

I have data in two separate xl sheets, one is the source sheet and the other is data sheet, now I have some empty cells in data sheet which can be filled by referencing the source sheet.

To be precise, for example the source sheet has column A,B,C and the data sheet has a column A which has similar data values as the column A of the source sheet, but repeated values…..

So I need a condition which checks the column A in both source and data sheets and if it finds the value in the data sheet’s column A to be similar to the value in the column A of the source sheet, then the corresponding B,C values from the source sheet are copied into the corresponding columns in data sheet…

Please help



 
Do you think something like this:

Dim wbIn As Workbook, wbOut As Workbook
Dim wshIn As Worksheet, wshOut As Worksheet
Dim celIn As Range, celOut As Range

Sub TransferData()
Dim RowsCount1 As Long, RowsCount2 As Long
' find and assign rows count for each sheet, e.g
RowsCount1 = 20
RowsCount2 = 100

Set wbIn = Workbooks("BookIn.xls") ' data sheet
Set wbOut = Workbooks("BookOut.xls") ' source sheet
Set wshIn = wbIn.Worksheets(1)
Set wshOut = wbOut.Worksheets(1)

For Each celOut In wshOut.Range("A2:A" & RowsCount1).Cells
' Your Exit condition here
' e.g: If IsEmpty(celOut) Then Exit For
' or: If cout.Value = "Total" Then Exit For

For Each celIn In wshIn.Range("A2:A" & RowsCount2).Cells
' Your Exit condition here
If celIn = celOut Then
celOut.Offset(0, 1) = celIn.Offset(0, 1)
celOut.Offset(0, 2) = celIn.Offset(0, 2)
End If
Next
Next
End Sub
 
Do you mean that for col A, if corresponding row values are IDENTICAL then the row values for columns B & C will be placed into the data sheet from the source sheet?
Please clarify.

metzgsk@voghtaircraft.com
 
Value in Output Sheet column "A" is key. Programm is loking for identical value in Input Sheet column "A".
If programm find identical value in Input Sheet column "A", it fill Output Sheet columns "B" & "C" by values from Input Sheet columns "B" & "C". Is it OK ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top