VBA IDEAS for Loop - Please

mole999

Well-known Member
Joined
Oct 23, 2004
Messages
10,524
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
I pull data from an SQL backend, which has to be processed, I have no ability to update the stored data, apart from CASE / REPLACE TYPES.

I have an Excel Sheet with updated values, and data that is important but not collected in the SQL.

Basically I have two tables, I have one common value that looks like Y0777 (23,000) of them

I need to look at my updated table, and then check around 15 columns cell by cell (not necessarily ABCDE type order) to see if a value exists, and if it is empty or different I need to replace the value. before I can continue to process the main updated file.

Any thoughts on a VBA loop that will scan down one column (Sheet 1) , find the appropriate main ref (Sheet 2) compare to the columns until that loop finishes.

The combination will then be processed to determine a range of values for reports

I don't mind if it takes 20 minutes to run through

my other option is index match into a third table, but I'd like to avoid doing that
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
SteveO59L
can't do real data i'm afraid

In essence

scan down Sheet1 Col A, compare against Sheet2 Col A, where a match exists for Col A, then look along into Col B and check if an identical values exists, is so ignore, if the col is blank or different value, copy the related value across. (No replacing values with BLANKS}

Excel Workbook
ABCDEFGH
1Sheet 1Sheet 2
2Col ACol BCol CCol ACol CCol B
3Y000118/08/2017Y0001e18/08/2017
4Y000217/07/2017sY0002s18/08/2017
5Y0003Y0004f
6Y0004dY0005e
7Y0005Y0006
8
Sheet1
 
Upvote 0
Not sure if I've understood you correctly, but could you use a dictionary?
Put the values in sheet1 col A as the key & the relevant row number as the item.
Then loop through the sheet 2 columns & if it exists in the dictionary compare the Col B value in sheet2 with sheet using the item?
Hope this is clear
 
Upvote 0
potentially over 30,000 rows at a max, and 10 columns, and I know nothing about dictionaries, but have read a few thesauruses' :).. I was thinking something slower FOR FOR with comparison NEXT NEXT, but don't have a good view in my head. I will get there eventually
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,021
Latest member
Mohamed Magdi Tawfiq Emam

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