Hey Guys!
I am currently a new member to the forum, but long I have been getting help from the community. It feels finally very nice to be an official part of the group
I came across a problem today while I was trying to establish a VBA code to do the following:
I have 12 sheets of detailed records, each comprises of some SAP outputs (13 columns: year/month/exact date/x/x/x/definition/x/x/process definition/financial value/x/x; with x's being irrelevant).
I am trying to filter them through their "month" and its financial value if it is above a limit stated at the first (homepage) worksheet.
I tried to establish a nested for loop (dual) and implement a conditionality within to check if "month" and "financial value>Blabla": and search for all existing worksheets in the workbook. Simultaneously, through the use of a row counter, the suitable data will be posted on the homepage worksheet with relevant headlines.
I am already getting some nicely sorted headlines but no relevant data are being published in the homepage worksheet.
As I have stated before, the code above results with properly placed headlines and table headers (thanks to i=i+1), but no relevant data from wsheets. Also the wsheets contain records compliant with the finValue and month variables.
I have tried every possible nested loop structure (do-while etc.) but had no better results. I guess the problem lies within my noobness :D
I am looking forward to getting needed help from you experts !
Thank you sincerely,
Cinarbe
Edit: The question is also posted on:
http://answers.microsoft.com/en-us/o...7-196cfb0f63dd
http://www.mrexcel.com/forum/excel-q...ml#post3307086
I am currently a new member to the forum, but long I have been getting help from the community. It feels finally very nice to be an official part of the group
I came across a problem today while I was trying to establish a VBA code to do the following:
I have 12 sheets of detailed records, each comprises of some SAP outputs (13 columns: year/month/exact date/x/x/x/definition/x/x/process definition/financial value/x/x; with x's being irrelevant).
I am trying to filter them through their "month" and its financial value if it is above a limit stated at the first (homepage) worksheet.
I tried to establish a nested for loop (dual) and implement a conditionality within to check if "month" and "financial value>Blabla": and search for all existing worksheets in the workbook. Simultaneously, through the use of a row counter, the suitable data will be posted on the homepage worksheet with relevant headlines.
I am already getting some nicely sorted headlines but no relevant data are being published in the homepage worksheet.
Code:
Sub ShowRecords()
Dim month, i, a, b As Integer
Dim finValue As Double
'following state the minimum fin. value limit and the month to be queried.
month = Worksheets(1).Cells(5, 4)
finValue= Worksheets(1).Cells(7, 8)
'homepage worksheet row counter
i = 10
Worksheets(1).Select
'navigating through all possible wsheets
For a = 1 To (ActiveWorkbook.Worksheets.Count - 1)
'publishing the wsheet headline in homepage
Worksheets(1).Cells(i, 3) = Worksheets(a + 1).Cells(1, 7)
i = i + 1
'publishing the wsheet table headers (relevants) in homepage
Worksheets(1).Cells(i, 3) = Worksheets(a + 1).Cells(3, 1)
Worksheets(1).Cells(i, 4) = Worksheets(a + 1).Cells(3, 2)
Worksheets(1).Cells(i, 5) = Worksheets(a + 1).Cells(3, 3)
Worksheets(1).Cells(i, 6) = Worksheets(a + 1).Cells(3, 7)
Worksheets(1).Cells(i, 7) = Worksheets(a + 1).Cells(3, 10)
Worksheets(1).Cells(i, 8) = Worksheets(a + 1).Cells(3, 11)
i = i + 1
'tried to establish a loop consisting of step equal to nonblank cells in active wsheet with the conditionality
For b = 4 To ((Worksheets(a + 1).Range("B:B").Cells.SpecialCells(xlCellTypeConstants).Count) + 2)
If Cells(b, 2) = month And Cells(b, 11) >= finValue Then
'publishing the relevant records' values in homepage wsheet
Worksheets(1).Cells(i, 3) = Worksheets(a + 1).Cells(b, 1)
Worksheets(1).Cells(i, 4) = Worksheets(a + 1).Cells(b, 2)
Worksheets(1).Cells(i, 5) = Worksheets(a + 1).Cells(b, 3)
Worksheets(1).Cells(i, 6) = Worksheets(a + 1).Cells(b, 7)
Worksheets(1).Cells(i, 7) = Worksheets(a + 1).Cells(b, 10)
Worksheets(1).Cells(i, 8) = Worksheets(a + 1).Cells(b, 11)
i = i + 1
End If
Next b
i = i + 1
Next a
Worksheets(1).Select
End Sub
As I have stated before, the code above results with properly placed headlines and table headers (thanks to i=i+1), but no relevant data from wsheets. Also the wsheets contain records compliant with the finValue and month variables.
I have tried every possible nested loop structure (do-while etc.) but had no better results. I guess the problem lies within my noobness :D
I am looking forward to getting needed help from you experts !
Thank you sincerely,
Cinarbe
Edit: The question is also posted on:
http://answers.microsoft.com/en-us/o...7-196cfb0f63dd
http://www.mrexcel.com/forum/excel-q...ml#post3307086
Last edited: