473,395 Members | 1,762 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

macro help needed

12
Hi all,
I need to write a macro for the following case, can anyone help me with it?

I have an excel sheet which has 6 columns, one column is Status, 2nd column is time and third col is pid. Now for any case there can be many "sets" of data having the same pid, but different status and times.

The staus could be Start, doing 1, doing 2, error1, complete.

I need to write something which can add another column to this worksheet and for each pid, give me the difference between times where status is complete minus start.

Can someone explain me how to do this?
Mar 4 '08 #1
3 888
kadghar
1,295 Expert 1GB
Hi all,
...

Can someone explain me how to do this?
Its not that hard, you should give it a try first. Google how to use FOR/NEXT , DO/LOOP, CELLS, and some array's managing.

If you have some particular doubts, we'll be glad to give you a hand or point you in the right direction.
Mar 4 '08 #2
ashishc
12
Hi,
I did write something, but its not working, so if you could help me with it that will be great. I am posting my sample from excel here. This is really urgent so if you could post some code, that will be great.

Thanks


This is what my excel looks like

144B7FC1-0761-4CC0-A112-91AFFDA08411 StartingJob 23:56:29
144B7FC1-0761-4CC0-A112-91AFFDA08411 StartingModule 23:56:29
144B7FC1-0761-4CC0-A112-91AFFDA08411 StartingModule 23:56:29
144B7FC1-0761-4CC0-A112-91AFFDA08411 StartingModule 23:56:29
144B7FC1-0761-4CC0-A112-91AFFDA08411 StartingModule 23:56:29
144B7FC1-0761-4CC0-A112-91AFFDA08411 CompleteModule 23:57:53
144B7FC1-0761-4CC0-A112-91AFFDA08411 CompleteModule 23:57:53
144B7FC1-0761-4CC0-A112-91AFFDA08411 CompleteModule 23:57:53
144B7FC1-0761-4CC0-A112-91AFFDA08411 CompleteModule 23:57:53
144B7FC1-0761-4CC0-A112-91AFFDA08411 CompleteJob 23:57:53
144B7FC1-0761-4CC0-A112-91AFFDA08411 StartingJob 23:56:29
144B7FC1-0761-4CC0-A112-91AFFDA08411 StartingModule 23:56:29
144B7FC1-0761-4CC0-A112-91AFFDA08411 StartingModule 23:56:29
144B7FC1-0761-4CC0-A112-91AFFDA08411 StartingModule 23:56:29
144B7FC1-0761-4CC0-A112-91AFFDA08411 StartingModule 23:56:29
144B7FC1-0761-4CC0-A112-91AFFDA08411 CompleteModule 23:57:53
144B7FC1-0761-4CC0-A112-91AFFDA08411 CompleteModule 23:57:53
144B7FC1-0761-4CC0-A112-91AFFDA08411 CompleteModule 23:57:53
144B7FC1-0761-4CC0-A112-91AFFDA08411 CompleteModule 23:57:53
144B7FC1-0761-4CC0-A112-91AFFDA08411 CompleteJob 23:57:53
144B7FC1-0761-4CC0-A112-91AFFDA08411 StartingJob 23:56:22
144B7FC1-0761-4CC0-A112-91AFFDA08411 CompleteJob 23:57:43
Mar 4 '08 #3
kadghar
1,295 Expert 1GB
Hi,
I did write something, but its not working, so if you could help me with it that will be great. I am posting my sample from excel here. This is really urgent so if you could post some code, that will be great.
Thanks
...
Well, it'd have helped if you had showed us what you did in VBA, instead of your excel's sheet. I'll write an example; for this i'll have ID in the first column, Status in second and Time/Date in third. This will look for the first ID and its Start and Complete status, Then it'll show you the difference in a msg box

Expand|Select|Wrap|Line Numbers
  1. sub kad1()
  2. dim a
  3. dim i as long
  4. dim Dat1 as date: dim Dat2 as date
  5. a = range(cells(1,1), cells(1,1).end(-4121))
  6. for i= 1 to ubound(a)
  7.     if a(i,1) = a(1,1) and a(i,2) = "Start" then Dat1 = a(i,3)
  8.     if a(i,1) = a(1,1) and a(i,2) = "Complete" then Dat2 = a(i,3)
  9. next
  10. msgbox dat2-dat1
  11. end sub
This will give you an idea.

HTH
Mar 4 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

25
by: Andrew Dalke | last post by:
Here's a proposed Q&A for the FAQ based on a couple recent threads. Appropriate comments appreciated X.Y: Why doesn't Python have macros like in Lisp or Scheme? Before answering that, a...
0
by: Donald 'Paddy' McCarthy | last post by:
So, for those that don't actively not-want a Python macro facility. If we are to have it what should it do? 1) Macro definitions should allow Doc strings. 2) There should be a separate statement...
0
by: Newbillian | last post by:
After converting Access 97 databases to 2003 this error msg shows up after a line about not being able to save the record because a related record is needed in another table. The complete msg is: ...
6
by: MLH | last post by:
Did A97, perchance, do away with the need for an AutoExec macro to initiate an autoexec sequence for databases? Or, must we still suffer with that hideous macro?
17
by: sounak | last post by:
How could we get a macro name from a macro value such that in a header file #define a 100 #define b 200 now the source file will be such that the user gives 100 then the value is outputted as...
6
by: Takeadoe | last post by:
Dear NG, Can someone assist me with writing the little code that is needed to run an update table query each time the database is opened? From what I've been able to glean from this group, the...
3
by: swb76 | last post by:
Hi, I have 6 queries in Access that run great. They need to be run in sequence with the first 5 queries writing to tables and the sixth one pops up the final results in datasheet view. Now, how...
19
by: Tor Rustad | last post by:
I'm implementing a parser, where there is a lot of different data elements defined. Now instead of hand-coding X defines, and the massive number of lines needed for table initialization, I decided...
3
MMcCarthy
by: MMcCarthy | last post by:
Although some users find Macros simple and easy to use, there are some major limitations to using them. Although you can use macros to perform tasks, there is limited control on when and how those...
33
by: Peng Yu | last post by:
Hi, __PRETTY_FUNCTION__ is a macro that gives function name, etc. I'm wondering if there is a macro to get the class name inside a member function. Thanks, Peng
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.