Calibrations

L

Legacy 436357

Guest
Hi,

I was wondering if someone can help me please. I have a long list of equipment that requires calibrations on different cycles. Some weekly, monthly, semi-annual, and annual. I request some sort of way to automate the process as far as showing what is due.

I would like to attach file example if possible.

Thank you very much,
Bill
 
Hi and thank you for the code. I changed my sheet to Equipment and assigned it to a shape. When clicking it went to debug mode and highlighted the line:

If Month(AR(i, 1)) = 11 Then

Code:
Sub CopyNovember()
Dim wsEquip  As Worksheet: Set wsEquip = Sheets("Equipment") 'Change sheet to whatever yours is named
Dim wsNov   As Worksheet: Set wsNov = Sheets("November")
Dim AR()    As Variant: AR = wsEquip.Range("A1").CurrentRegion.Value
Dim LR      As Long
Dim R       As Range




For i = 2 To UBound(AR)
    If Month(AR(i, 1)) = 11 Then
        LR = wsNov.Range("A" & Rows.Count).End(xlUp).Row() + 1
        Set R = wsNov.Range("A" & LR).Resize(1, UBound(AR, 2))
        tmp = Application.Index(AR, i, 0)
        R.Value = tmp
    End If
Next i




End Sub
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I ran into that error as well. It happens when the value in the array isn't a date. That's why the for loop starts at 2, to skip the header row. At least I am guessing it's the same error. Does your data start in A1 on your 'Equipment' sheet? If it is just a matter of the value not being a date, the code below should be able to handle it.

Code:
Sub CopyNovember()


Dim wsMain  As Worksheet: Set wsMain = Sheets("Equipment") 'Change sheet to whatever yours is named
Dim wsNov   As Worksheet: Set wsNov = Sheets("November")
Dim AR()    As Variant: AR = wsMain.Range("A1").CurrentRegion.Value
Dim LR      As Long
Dim R       As Range


For i = 2 To UBound(AR)
    If IsDate(AR(i, 1)) Then
        If Month(AR(i, 1)) = 11 Then
            LR = wsNov.Range("A" & Rows.Count).End(xlUp).Row() + 1
            Set R = wsNov.Range("A" & LR).Resize(1, UBound(AR, 2))
            tmp = Application.Index(AR, i, 0)
            R.Value = tmp
        End If
    End If
Next i


End Sub
 
Last edited:
Upvote 0
The data starts in A3 on both sheets. They are also both tables does that matter?
 
Upvote 0
Yeah, try this one...

Code:
Sub CopyNovember()


Dim wsMain  As Worksheet: Set wsMain = Sheets("Equipment") 'Change sheet to whatever yours is named
Dim wsNov   As Worksheet: Set wsNov = Sheets("November")
Dim AR()    As Variant: AR = wsMain.Range("A3").CurrentRegion.Value
Dim LR      As Long
Dim R       As Range


For i = 2 To UBound(AR)
    If IsDate(AR(i, 1)) Then
        If Month(AR(i, 1)) = 11 Then
            LR = wsNov.Range("A" & Rows.Count).End(xlUp).Row() + 1
            Set R = wsNov.Range("A" & LR).Resize(1, UBound(AR, 2))
            tmp = Application.Index(AR, i, 0)
            R.Value = tmp
        End If
    End If
Next i


End Sub
 
Upvote 0
It is working with that latest code thanks. I did some trials and what it does now it will pull all November's lines (checking the date) which is great. Is there a way to check to see if those lines were already posted so there aren't duplicates? Maybe it's too much to ask sorry if that is the case. I do appreciate the help.
 
Upvote 0
It is working with that latest code thanks. I did some trials and what it does now it will pull all November's lines (checking the date) which is great. Is there a way to check to see if those lines were already posted so there aren't duplicates? Maybe it's too much to ask sorry if that is the case. I do appreciate the help.

probably better to pull all the right data, then delete the new duplicates, rather than complex checks
 
Upvote 0
I agree thank you very much for the help. Is there a way to say this is solved?
 
Upvote 0
This code will copy everything over and then remove duplicates at the end. Let me know if it works for you.

Code:
Sub CopyNovember()


Dim wsMain  As Worksheet: Set wsMain = Sheets("Equipment") 
Dim wsNov   As Worksheet: Set wsNov = Sheets("November")
Dim AR()    As Variant: AR = wsMain.Range("A3").CurrentRegion.Value
Dim LR      As Long
Dim R       As Range


For i = 2 To UBound(AR)
    If IsDate(AR(i, 1)) Then
        If Month(AR(i, 1)) = 11 Then
            LR = wsNov.Range("A" & Rows.Count).End(xlUp).Row() + 1
            Set R = wsNov.Range("A" & LR).Resize(1, UBound(AR, 2))
            tmp = Application.Index(AR, i, 0)
            R.Value = tmp
        End If
    End If
Next i


Set R = wsNov.Range("A3").CurrentRegion
R.RemoveDuplicates Columns:=Array(1, 2, 3, 4, 5, 6, 7, 8, 9), Header:=xlYes


End Sub
 
Upvote 0
Wow that's fantastic! Thank you so much for the great help. How does it check for November dates only? Just curious...
 
Last edited by a moderator:
Upvote 0
its set in the code for November and also month = 11
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top