Don't worry I am not imposing this code on you to handle. I just want an 
idea for doing this.  This is about to highlight some rows data with the 
help of conditional formatting. numerous of files reside in directory. I 
want to iterate each file with the help of code which is working correctly. 
 

Due to overlapping of rows while filtering and then applying conditional 
formatting. the code gives error. while recording the macro and running it. 
Getting Runtime Error 1004 when Coding Conditional Formats with VBA same 
problem arise with many people in forums. the conclusion turned into the 
resolution that overlapping of rows while filtering and applying 
formatting. 

http://www.mrexcel.com/forum/excel-questions/570444-run-macro-all-files.html


Result should be like 

1) in Time row :- if time is greater then 10:05:00 Am highlight red 
2) total time row :- if total time is less than 6:30 hours. highlight  red 
 


Sub Biometric_Reports()

Dim bookList As Workbook
Dim mergeObj As Object, dirObj As Object, filesObj As Object, everyObj As 
Object
Application.ScreenUpdating = False
Set mergeObj = CreateObject("Scripting.FileSystemObject")

'change folder path of excel files here
Set dirObj = mergeObj.Getfolder("C:\Users\pc\Desktop\Payment Analysis\June")
Set filesObj = dirObj.Files
For Each everyObj In filesObj

Set bookList = Workbooks.Open(everyObj)
Sheets(1).select 

    Dim nRows As Integer
    Dim nCols As Integer
    Dim R As Integer
    Dim C As Integer
    
    Range("A1").Select
    nRows = ActiveCell.SpecialCells(xlLastCell).Row
    MsgBox nRows
    
    nCols = ActiveCell.SpecialCells(xlLastCell).Column
    
    MsgBox nCols
    
    Range(Cells(2, 1), Cells(nRows, nCols)).Select
    Selection.UnMerge
    With Selection
        .HorizontalAlignment = xlGeneral
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Selection.ColumnWidth = 4
    If ((ActiveSheet.Range("A1").Value & "X" = "X") _
    And (ActiveSheet.Range("B1").Value & "X" <> "X")) Then
        Debug.Assert True
        ActiveSheet.Range("A1").Delete Shift:=xlToLeft
'        ActiveSheet.Range("A1").Value = ActiveSheet.Range("B1").Value
'        ActiveSheet.Range("B1").Value = ""
    End If
    For C = nCols To 1 Step -1
        If (Application.WorksheetFunction.CountA(Range(Cells(1, C), 
Cells(nRows, C))) = 0) Then
'            Cells(1, C).EntireColumn.Select
            Debug.Assert True
            Cells(1, C).EntireColumn.Delete Shift:=xlToLeft
            Debug.Assert True
        End If
    Next C
    Range("AE6:Al500").Select
    Selection.Copy
    Selection.Offset(0, -1).PasteSpecial Paste:=xlPasteValues
    
    Range("U6:AK500").Select
    Selection.Copy
    Selection.Offset(0, -1).PasteSpecial Paste:=xlPasteValues
    
    Range("P6:AK500").Select
    Selection.Copy
    Selection.Offset(0, -1).PasteSpecial Paste:=xlPasteValues
    
    Range("E6:AK500").Select
    Selection.Copy
    Selection.Offset(0, -1).PasteSpecial Paste:=xlPasteValues
    
   
End Sub



-- 
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 http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to