Compare Rows to Columns in Different Sheets

weaverae

New Member
Joined
Sep 15, 2013
Messages
1
Hello Everyone,

I am very to new to VBA and have run into some difficulties early on. Currently I have a tabs "IDB_CapEx", "IDB_OpEx", and "RCM".

The RCM contains a variable number of columns with the row information as follows:
Row 2: Project Name
Row 3: Project Number
Row 4: Project Manager
Row 5: Release Date

If the Project number contains "Opex"; the Project Name, Project Manager, and Release Date are compared to the "IDB_OpEx" sheet. If Project Name isn't found, it creates a new entry at the end of the list. If it is found, it updates that project to match the "RCM" information.

I know this is very specific, but I wanted to give as much background as possible. My question is, how do I go about having the script go through an unspecified number of rows and then compare that to columns in another sheet?

Any help would be much appreciated. This is just the beginning of what I want to write but also want to learn for the future.

Thanks.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi,

When the number of columns or rows in not known yet, I usually search for an 'always filled' column or row.
Lets say for example that column A is always filled and you wanted to match a value to the values in column C that is not always filled.
I would loop over all rows untill columns A is empty like this
Code:
    Dim FoundIt As Boolean
    Dim MatchRow As Long
    Dim R As Long
    
    'First row to try for matching
    R = 1
    FoundIt = False
    MatchRow = 0
    'Loop untill column A is empty
    While Not FoundIt And Sheets("Sheet1").Cells(R, "A").Value <> ""
        If Sheets("Sheet1").Cells(R, "C").Value = WhatImLookingFor Then
            MatchRow = R
            FoundIt = True
        End If
        'Try next row
        R = R + 1
    Wend
    'Here you can process row MatchRow

Does this help?
 
Upvote 0

Forum statistics

Threads
1,215,892
Messages
6,127,613
Members
449,390
Latest member
joan12

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top