tekkenking
New Member
Hi
Narayan has been extremely kind in helping me with an excel sheet (see http://chandoo.org/forums/topic/saving-whilst-using-advanced-filters?replies=1#post-89762 if interested).
There is some VBA code he had written and I was wondering if anybody could help me in deciphering it.
Any sort of commentary to put it in context would be extremely useful for my learning especially since I would now like to manipulate by adding rows/columns.
I am particularly interested in this portion:
[pre]
[/pre]
Narayan if you could answer that would be fantastic, however I fear I may have taken up a lot of your time with this - so if there is anybody out there who could help, I would be extremely grateful.
Many thanks.
Narayan has been extremely kind in helping me with an excel sheet (see http://chandoo.org/forums/topic/saving-whilst-using-advanced-filters?replies=1#post-89762 if interested).
There is some VBA code he had written and I was wondering if anybody could help me in deciphering it.
Any sort of commentary to put it in context would be extremely useful for my learning especially since I would now like to manipulate by adding rows/columns.
I am particularly interested in this portion:
[pre]
Code:
Public Sub Transfer()
Dim from_array As Variant, to_array As Variant
Range("Output").Cells(2, 1).Select
number_of_rows = ActiveCell.CurrentRegion.Rows.Count - 1
number_of_columns = Range("Output").Columns.Count
from_array = ActiveCell.Resize(number_of_rows, number_of_columns).Value
Worksheets("SalesRecord").Activate
Range("Data_Range").Cells(2, 1).Select
number_of_rows = ActiveCell.CurrentRegion.Rows.Count - 1
number_of_columns = ActiveCell.CurrentRegion.Columns.Count
to_array = ActiveCell.Resize(number_of_rows, number_of_columns).Value
For i = LBound(to_array, 1) To UBound(to_array, 1)
cell = to_array(i, 1)
If cell = Worksheets("Snapshot").Range("Criteria").Cells(2, 1).Value Then
st = to_array(i, 2)
pt = to_array(i, 3)
qt = to_array(i, 4)
For j = LBound(from_array, 1) To UBound(from_array, 1)
sf = from_array(j, 2)
pf = from_array(j, 3)
qf = from_array(j, 4)
cf = from_array(j, 5)
If ((st = sf) And (pt = pf) And (qt = qf)) Then
ActiveCell.Offset(i - 1, 4).Value = cf
End If
Next
End If
Next
End Sub
Narayan if you could answer that would be fantastic, however I fear I may have taken up a lot of your time with this - so if there is anybody out there who could help, I would be extremely grateful.
Many thanks.