Probably a simple VBA code but I am new to all this...

MartinLe50

New Member
Joined
Aug 28, 2020
Messages
7
Office Version
  1. 2016
Platform
  1. Windows
I am new to VBA, the chart below shows the grey number cells and white number cells. The white cells are just like an ID cell to the grey cells, they represent the number of days. The grey cells represent the number of dollars during that duration of time.

Every number in the grey cells have another grey cell number cell that when multiplied by 2 yields it's double. For example the value of (5 and 10), (10 and 20), (20 and 40), (30 and 60) etc... I want to know how to write out the code to populated this data with the white cells which represent the number of days.

I supposed a For Next Loop would have to go through the grey numbers cells and then a variable is assigned from the white cells to the grey cells. Then again, I am kind of new to this and a couple of command codes or instructions how to do this would be great! New photo added to shared album
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Kindly share the answer sheet that you need to display
 
Upvote 0
Share Excel file please. Can't give solution through images
How can you upload a file it only allows an image on attachment?
Anyways, someone insisted this... do you know what if this would work?

1) create 2 for next loops

1 for columns

other for rows

outer loops is for columns inner loops is for rows

use step 1 on column loop to skip 1 column (white column)

then create 2 variable

let call this. val1, val2

val1 = current cell (using cells(r,c).value)) value

val2 = cell to be search (using cells(r,c).value * 2) value

then create a range variable. let call this cFound

then use vba find command to search val2 (use lookin xlvalues, lookat xlwhole)

use cfound variable to save cell address in which val2 is found.

then add if condition after find command

if not cfound is nothing then

inside this if codition create another string variable

let call this cfoundAddress

and store cfound addrees in it. (this is you 1st found address)

then create a do loop after this (inside if condition)

in this do loop

add a code to save your found value in another sheet or do what ever you want to do

then use vba find next to find next value (value equal to val2)

and then close the loop with condtion (loop while your cfound is not equal to your 1st cfound address

loop until cfound.address = cfoundaddress

end if

 
Upvote 0

Forum statistics

Threads
1,214,659
Messages
6,120,781
Members
448,992
Latest member
prabhuk279

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