• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Need help on VBA

Status
Not open for further replies.

yathish

New Member
Hi there

Please help me with a VBA code to get the below things from a machine log file,


Info:-

1. One cycle means Time between Process start and Process end, Refer column C in the workbook.

2. Machine interruptions are captured in column E.

3. Cycle time, i,e; Time difference between process start and process end for each cycle in the column F

Requirement:-

1, If there is any interruption in any cycle, it is not a success run, So success should not come in column G,

2, If there is no any interruptions in a cycle, it is a success run so success should come in the respective row,

Currently, I am using a macro which inserts the formula for some cells,

All calculated values should come in respective rows in column I.

Please help me as soon as possible.

Thanks,
Yathi
 

Attachments

  • Book1.xlsx
    264.3 KB · Views: 5
This will do what you ask.
Code:
Sub CheckSuccess()
Dim ws As Worksheet
Dim lastRow As Long
Dim timeStart As Date
Dim i As Long
Dim boolGood As Boolean

'Which worksheet are we dealing with?
Set ws = ActiveSheet

Application.ScreenUpdating = False
With ws
    'Find last row with data
    lastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
   
    'loop over the cells
    For i = 2 To lastRow
        Select Case UCase(.Cells(i, "C").Value)
       
        'Check if we're at the beginning or end
        Case "RECIPE START"
            boolGood = True
            timeStart = .Cells(i, "B").Value
        Case "RECIPE END"
            'Give outputs
            .Cells(i, "F").Value = .Cells(i, "B").Value - timeStart
            If boolGood Then
                .Cells(i, "G").Value = "Success"
            Else
                .Cells(i, "G").Value = "Failure"
            End If
        'Otherwise, check if an interruption occurred
        Case Else
            If .Cells(i, "E").Value <> "" Then
                boolGood = False
            End If
        End Select
    Next i
End With
Application.ScreenUpdating = True
   
End Sub
 
Hi every one

I am a new user

I would really appreciate if anybody helps me.

I want a micro VBA Code for the following criteria:

I tried excel formulas but that erases data if condition changes

I have changing data in Row (1) I want this data be posted every time it changes to assigned months in Rows (A7 to A18)

For Which My excel table has following data:

Where As Cells (A7 to A18) contain names of months (April to March)

I want (If A1 = “April) “data be posted (copy & paste special values only) in Row-7 (based on months mentioned above). Which means if A1 matches with A7 data is posted in Row 7, If (A1= “May” means if A1 matches with A8) data be posted to Row 8 so on…… & data should remain protected in that very row until the A1 again matches with that month.

Do I need to record a module ???

OR

Do I need 12 macros

Or

It can be solved in just 1 macro ???



IF ANYBODY COULD GIVE ME CODE PLEASE.



Thanks in advance
 

Attachments

  • MDM Register.xlsx
    11.7 KB · Views: 0
Status
Not open for further replies.
Back
Top