Fill 2 dimension array from a vertical range of cell (and subtract values)

woofie

New Member
Joined
Mar 8, 2016
Messages
8
I may need your help again as i'm trying to build on the code that was previously suggested by another user here when I needed help on fill 2 dimension array from a vertical range of cell.

Code:
Sub FillB5M15FromA76A197()
  Dim R As Long
  For R = 76 To 207 Step 12
  
      Sheets("SheetA").Range("B5").Offset(Int((R - 76) / 12)).Resize(, 12) = Application.Transpose(Sheets("SheetB").Cells(R, Sheets("SheetA").Range("A1").Value).Resize(12))
    
  Next
End Sub

ISSUE: If you guys have noticed, the purpose of the above is just to extract out the data out directly from the SheetB and fill in SheetA B5 to M15. Now, I would like to bring a notch higher. Before i extract the value from SheetB, I would like to subtract the extracted the value with the corresponding cell in another column, say Z (which is fixed no matter which column of data im extracting initially)

It'll be something like that:
If SheetB's column A data is extracted:
Sheet A B5 = Sheet B A76 - Z76
Sheet A C5 = Sheet B A77 - Z77
Sheet A D5 = Sheet B A78 - Z78...

If SheetB's column B data is extracted:
Sheet A B5 = Sheet B B76 - Z76
Sheet A C5 = Sheet B B77 - Z77
Sheet A D5 = Sheet B B78 - Z78...


Hope you guys can help me once again.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
bumpz, any savior? :(
Try this:
Code:
Sub a933855()
Dim vx, va, vb, i As Long, j As Long, k As Long
va = sheets("SheetB").Range("A76:A207")
vb = sheets("SheetB").Range("Z76:Z207")
ReDim vx(1 To 11, 1 To 12)

For i = 1 To 11
    For j = 1 To 12
    k = k + 1
    vx(i, j) = va(k, 1) - vb(k, 1)
    Next
Next

sheets("SheetA").Range("B5:M15").Value = vx
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,893
Members
449,097
Latest member
dbomb1414

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