PDA

View Full Version : [SOLVED] VBA MACRO CODE FOR GROUPING THE DATA BASED ON 2 HOURS TIME...



Dharani
04-26-2014, 11:52 PM
Hello Experts,

I need a VBA macro code to get the output like in the excel file which I have attached with this thread. Which means, I need to group the data for every two hours. in the output I need all 4 cols namely A, B, C, D along with extra col namely, interval based on which I need these groupings to be done..

I did manually for your kind reference and easy understanding... please find the attachment.... in the excel sheet I have explained still more clearly, please refer that...

A kind request, the code has to be really flexible so that it works for all dates and times in the files. because like this I have to do for 2000 files.....
I hope I am clear and I am not confusing you experts and also I hope for experts like you this code will be easier to write...
for further clarification, I am very much ready to answer you...

Looking forward for the positive reply..... please do the needful...
Thank you,

With kind regards,
Dharani.

dipique
04-28-2014, 07:07 AM
Dharani,

It's not quite clear what you're going for, but here's the information we need to help you:

1. What are you trying to accomplish? Do you have a group of files and you're trying to summarize the data into one sheet? Or do you have a list (like the one attached) and you need to categorize the items in that list?
2. What are the exact operations & business rules by which you derive your output? It looks like you placing certain values into intervals--what are those intervals, and what is the starting value?
3. You've done some formatting (highlighting, deleting some values)--is that part of the macro as well?

If you can help us understand what you want, we can be a lot more helpful in guiding you.

Lastly: by and large, this forum will not write code for you. We'll certainly help solve specific problems, but nobody here will do your work for you. So take a stab at it, and then when you get stuck, post your specific problem and we'll help you out.

A great place to start is reading and writing cell values. To do that, just go like this:



'To write:
Dim lRow as Long
Dim lColumn as Long
Dim sNewValue as String
'Set the variables to the desired values here
CurrentSheet.Cells(lRow,lColumn) = sNewValue
'Now that cell has the value you assigned it

'To read:
Dim lRow as Long
Dim lColumn as Long
Dim sCurrentValue as String
'Set the variables to the desired values here
sCurrentValue = CurrentSheet.Cells(lRow,lColumn)
'now sCurrentValue holds the value of that cell

'You can reference another worksheet's cell like this:
sCurrentValue = Worksheets("Sheet1").CurrentSheet.Cells(lRow,lColumn)


Hopefully that will get you started. Good luck!

Dan

Dharani
04-29-2014, 12:38 AM
THANK YOU SO MUCH FOR SPENDING YOUR VALUABLE TIME IN HELPING ME TO SORT OUT MY PROBLEM...
THANK YOU...

WITH KIND REGARDS,
DHARANI.