ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop thru two sets of numbers (https://www.excelbanter.com/excel-programming/368668-loop-thru-two-sets-numbers.html)

jeffbert

Loop thru two sets of numbers
 
I am new to VBA, basically I record macros/get help here and then manipulate
the code until it works.

I have a macro written to input data into certain cells. The user inputs the
sku # and then inputs the location #, and then the macro is fired. I have a
set list with one hundred skus, and twenty location numbers. What I would
like to do is have Excel look at the first sku number (13328960) and run the
process for each of the twenty locations (161, 181, 182, etc, etc). Once done
with the twenty locations, then go to the next sku number (13328978) and
repeat the process until there are no more sku numbers.

161 181 182 188
13328960
13328978
13328994
13329001

I appreciate any direction that you can give, whether sample code or
references to review.

Many thanks

Jeff


Tom Ogilvy

Loop thru two sets of numbers
 
Dim rng as Range, rng1 as Range
dim cell as Range, cell1 as Range
set rng = range(cells(2,1),cells(2,1).End(xldown)
for each cell in rng
rng1 = cell.offset(0,1).Resize(1,20)
for each cell1 in rng1
cell1.activate
loc = cells(1,cell1.column)
sku = cell.value
' run macro
next
next

--
Regards,
Tom Ogilvy



"jeffbert" wrote:

I am new to VBA, basically I record macros/get help here and then manipulate
the code until it works.

I have a macro written to input data into certain cells. The user inputs the
sku # and then inputs the location #, and then the macro is fired. I have a
set list with one hundred skus, and twenty location numbers. What I would
like to do is have Excel look at the first sku number (13328960) and run the
process for each of the twenty locations (161, 181, 182, etc, etc). Once done
with the twenty locations, then go to the next sku number (13328978) and
repeat the process until there are no more sku numbers.

161 181 182 188
13328960
13328978
13328994
13329001

I appreciate any direction that you can give, whether sample code or
references to review.

Many thanks

Jeff



All times are GMT +1. The time now is 03:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com