Sub chkdt()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim rw, cl, i, q As Double 'rw - no of used rows, cl - no of used column, i 
- lookup for row,q - lookup for column
Dim dif, t, dt As Long
t = 4
dt = 5

rw = ThisWorkbook.Sheets("MINUTES").Range("A" & Rows.Count).End(xlUp).Row
cl = ThisWorkbook.Sheets("MINUTES").Range("A1").End(xlToRight).Column
ThisWorkbook.Sheets("MINUTES").Range(Cells(8, 2), Cells(rw, cl)).Clear
    

For q = 2 To cl ' column lookup
    For i = 8 To rw ' row loookup
  dif = Round((ThisWorkbook.Sheets("MINUTES").Cells(dt, q) - 
ThisWorkbook.Sheets("MINUTES").Cells(t, q)) * 24 * 60, 0) - 1
  
    If (ThisWorkbook.Sheets("MINUTES").Cells(i, 1) >= 
ThisWorkbook.Sheets("MINUTES").Cells(t, q)) And _
        (ThisWorkbook.Sheets("MINUTES").Cells(i, 1) < 
ThisWorkbook.Sheets("MINUTES").Cells(dt, q)) Then
        DoEvents
        ThisWorkbook.Sheets("MINUTES").Range(Cells(i, q), Cells(i + dif, 
q)) = 1
        i = rw
    End If

    Next i
Next q

MsgBox "completed"
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub
======================
Thanks to everyone who helped

Cheers
Ravi

On Saturday, December 16, 2017 at 11:44:17 AM UTC+5:30, Ravi K wrote:
>
> Hi
>
> Can someone please explain why this macro does not work
> I have no formal training in VB or any programming so everything in the 
> macro is bits taken from various posts
>
> What I need to do is put 1 or 0 over a range that starts at B8 and ends at 
> the last column  with data at row 44652
> but if I leave the formula "=IF(AND(RC1>R4C,RC1<R5C),1,0)" in the place 
> the workbook becomes too large and  my i5 laptop hangs so I have to convert 
> the formula into the result value 1 or 0
>
> ===========================
> Sub FillCellsMyRange()
>
> ' Change the WorkSheet Name
> Dim shName As String
> Dim currentName As String
> currentName = ActiveSheet.Name
> shName = "MINUTES"
> If currentName <> shName Then
> ThisWorkbook.Sheets(currentName).Name = shName
> End If
>
> Dim LastCol As Long
>     With ActiveSheet.UsedRange
>         LastCol = .Columns(.Columns.Count).Column
>     End With
> Dim LastRow As Long, Rng1 As Long
> LastRow = Cells.Find(What:="*", After:=Range("A1"), SearchOrder:=xlByRows, 
> SearchDirection:=xlPrevious).Row
>
> 'Set Rng1 = Sheets("MINUTES").Range("B8:" & LastCol &  "44652")
> 'ActiveWorkbook.Names.Add Name:="MyRange", RefersTo:=Rng1
>
>
>     ' Turn off screen updating to improve performance
>     Application.ScreenUpdating = False
>     On Error Resume Next
>
>
>     ' Look in column B
>     With Sheets("MINUTES").Range("B8:" & LastCol & LastRow)
>         ' For blank cells, set them to equal the cell above
>         .SpecialCells(xlCellTypeBlanks).Formula = 
> "=IF(AND(RC1>R4C,RC1<R5C),1,0)"
>         'Convert the formula to a value
>         .Value = .Value
>     End With
>     Err.Clear
>     Application.ScreenUpdating = True
> End Sub
> =================================
>
> again, nothing above is original work, it is all copy & paste of what 
> looked like useful bits from various answers on various groups 
>
> Thanks again
>
> Ravi
>
>
>

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at https://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to