Copy value from one cell to balance cells in same row

Vincent88

Active Member
Joined
Mar 5, 2021
Messages
382
Office Version
  1. 2019
Platform
  1. Windows
  2. Mobile
Hi Guys, I want to copy value of a cell at the 1st day of a month to rest of the workdays that month in the same row if the cell in column A is not empty. Appreciate any help !



AgentProposal_Roster0728_0829.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKAL
1MDateAttendance27-Jul28-Jul29-Jul30-Jul31-Jul1-Aug2-Aug3-Aug4-Aug5-Aug6-Aug7-Aug8-Aug9-Aug10-Aug11-Aug12-Aug13-Aug14-Aug15-Aug16-Aug17-Aug18-Aug19-Aug20-Aug21-Aug22-Aug23-Aug24-Aug25-Aug26-Aug27-Aug28-Aug29-Aug30-Aug31-Aug
2DateSummary(5)(4)(3)(2)(1)12345678910111213141516171819202122232425262728293031
3Mary WT:22 L:0 D:1 E:0 N:0GGGGGD
4M JoshT:22 L:0 D:0 E:0 N:0DDDDD
5C RossiniT:22 L:0 D:0 E:0 N:0EEEEE
6J WcmathT:22 L:0 D:0 E:0 N:0D4PMD4D4AL
7T:22 L:0 D:0 E:0 N:0DDVLVLD
8T:22 L:0 D:0 E:0 N:0DDDD
9T:22 L:0 D:0 E:0 N:0DDDD
10T:22 L:0 D:0 E:0 N:0DDDD
11T:22 L:0 D:0 E:0 N:0VLVLDD
12T:22 L:0 D:0 E:0 N:0DDDDD
13T:22 L:0 D:0 E:0 N:0DNDD
14T:22 L:0 D:0 E:0 N:0DDDDD
202108
Cells with Data Validation
CellAllowCriteria
H3:AL14List=ShiftcodeNew
A3:A13List=HelpAgent
A14List=HelpAgent



Code:
Public Function IsHolWeekend(InputDate As Date) As Boolean

    Dim vLastRow As Long
    Dim vR1 As Range

    With ThisWorkbook.Worksheets("Data")
        vLastRow = .Cells(Rows.Count, "A").End(xlUp).Row
        For Each vR1 In .Range("A2:A" & vLastRow)
            If Day(InputDate) = Day(vR1) And _
               Month(InputDate) = Month(vR1) And _
               Year(InputDate) = Year(vR1) Or _
               Weekday(InputDate) = 1 Or _
               Weekday(InputDate) = 7 Then
               IsHolWeekend = True
               Exit Function
            Else
               IsHolWeekend = False
            End If
        Next vR1
     End With
    
End Function


Sub AutoInput9()


Dim aRng As Range, aRng1 As Range
Dim alastRow As Long, alastCol As Long
Dim aRngCol As Range, aRngRow As Range


alastRow = Cells(Rows.Count, "A").End(xlUp).Row
alastCol = Cells(1, Columns.Count).End(xlToLeft).Column


Set aRng = Range(Cells(1, 1), Cells(alastRow & alastCol))
Set aRngRow = Range(Cells(1, 3), Cells(1, alastCol))

    
'Locate the columns of the first and last dates of the month
aDayB1 = CDate(Format(ActiveSheet.Name, "0000-00"))
aDayE1 = DateAdd("m", 1, aDayB1) - 1
Set acolumnB1 = aRngRow.Find(aDayB1, , xlFormulas)
Set acolumnE1 = aRngRow.Find(aDayE1, , xlFormulas)

Debug.Print acolumnB1.Address, acolumnE1.Address

Dim aRngInput As Range
Set aRngInput = Range(Cells(3, acolumnB1.Column + 1), Cells(alastRow, acolumnE1.Column))

Debug.Print aRngInput.Address
 
 If aRng.Rows.Count > 2 Then
        Set aRng1 = Intersect(Target, aRng.Offset(1, 0).Resize(aRng.Rows.Count - 1, aRng.Columns.Count))
    Else
       Set aRng1 = Nothing
    End If

    If Not aRng1 Is Nothing Then
        If Target.Column = 1 And Not (IsEmpty(Target)) Then
           If IsHolWeekend(aRngRow.Cells(1)) = False Then
             Target.Value = Target.aRngInput.Value
             End If
                End If
                  End If

End Sub
 
Hi, I use sheet of Feb 2022. The dates range consists of Jan to March. Feb 4 is the 1st work day in Feb

AgentProposal_Roster0728_0829.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKAL
1MDateAttendance27-Jan28-Jan29-Jan30-Jan31-Jan1-Feb2-Feb3-Feb4-Feb5-Feb6-Feb7-Feb8-Feb9-Feb10-Feb11-Feb12-Feb13-Feb14-Feb15-Feb16-Feb17-Feb18-Feb19-Feb20-Feb21-Feb22-Feb23-Feb24-Feb25-Feb26-Feb27-Feb28-Feb1-Mar2-Mar3-Mar
2DateSummary(5)(4)(3)(2)(1)12345678910111213141516171819202122232425262728293031
3Mary WT:17 L:0 D:0 E:0 N:0GGGE
4M JoshT:17 L:0 D:0 E:0 N:0EEEG
5C RossiniT:17 L:0 D:0 E:0 N:0NNN
6J WcmathT:17 L:0 D:0 E:0 N:0DDD
7T:17 L:0 D:0 E:0 N:0D3D3D3
8T:17 L:0 D:0 E:0 N:0D2D2D2
9T:17 L:0 D:0 E:0 N:0
10T:17 L:0 D:0 E:0 N:0DDDD
11T:17 L:0 D:0 E:0 N:0VLVLDD
12T:17 L:0 D:0 E:0 N:0DDDDD
13T:17 L:0 D:0 E:0 N:0DNDD
14T:17 L:0 D:0 E:0 N:0DDDDD
202202
Cells with Data Validation
CellAllowCriteria
H3:AL14List=ShiftcodeNew
A3:A13List=HelpAgent
A14List=HelpAgent
 
Upvote 0

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Sorry try this 3 macro:
VBA Code:
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
          If Sh.Name = "Data" Then Exit Sub
          Dim Lc&, Lr&, Lr2&, M&, F&, N&
          Lr = Range("A" & Rows.Count).End(xlUp).Row
          Lc = Cells(1, Columns.Count).End(xlToLeft).Column
          Lr2 = Sheets("Data").Range("A" & Rows.Count).End(xlUp).Row
        M = Application.Match(CLng(DateSerial(Year(Range("C1").Value), Month(Range("C1").Value) + 1, 0)) + 1, Rows(1), 0)
Resum1:
N = Lc + 1
N = Evaluate("=INDEX(" & Cells(1, M).Address & ":" & Cells(1, Lc).Address & ",MATCH(TRUE,COUNTIF(Data!A1:A" & Lr2 & "," & Cells(1, M).Address & ":" & Cells(1, Lc).Address & ")>0,0))")
N = Application.Match(N, Rows(1), 0)

Resum2:
        If Application.WorksheetFunction.NetworkDays(Cells(1, M).Value, Cells(1, M).Value) = 1 And N <> M Then
        Else
        M = M + 1
        If N < M Then GoTo Resum1
        GoTo Resum2
        End If

F = Application.Match(CLng(DateSerial(Year(Cells(1, M).Value), Month(Cells(1, M).Value) + 1, 0)), Rows(1), 0)
           If Intersect(Target, Range(Cells(2, M), Cells(2, M))) Is Nothing Then Exit Sub             'Apply to Row 2 in Range
            Cancel = True
          Application.DisplayAlerts = False
             FillNetworkDays
          Application.DisplayAlerts = True
 End Sub
VBA Code:
Sub FillNetworkDays()
On Error Resume Next
Dim i&, j&, C As String, R As String, S As Variant, Ca As Variant, Ra As Variant
Dim Lc&, Lr&, Lr2&, M&, F&, N&
Lr = Range("A" & Rows.Count).End(xlUp).Row
Lc = Cells(1, Columns.Count).End(xlToLeft).Column
Lr2 = Sheets("Data").Range("A" & Rows.Count).End(xlUp).Row
M = Application.Match(CLng(DateSerial(Year(Range("C1").Value), Month(Range("C1").Value) + 1, 0)) + 1, Rows(1), 0)
Resum1:
N = Lc + 1
N = Evaluate("=INDEX(" & Cells(1, M).Address & ":" & Cells(1, Lc).Address & ",MATCH(TRUE,COUNTIF(Data!A1:A" & Lr2 & "," & Cells(1, M).Address & ":" & Cells(1, Lc).Address & ")>0,0))")
N = Application.Match(N, Rows(1), 0)

Resum2:
        If Application.WorksheetFunction.NetworkDays(Cells(1, M).Value, Cells(1, M).Value) = 1 And N <> M Then
        Else
        M = M + 1
        If N < M Then GoTo Resum1
        GoTo Resum2
        End If

F = Application.Match(CLng(DateSerial(Year(Cells(1, M).Value), Month(Cells(1, M).Value) + 1, 0)), Rows(1), 0)
For j = M + 1 To F
N = 0
N = Application.Match(Cells(1, j).Value, Sheets("Data").Range("A1:A" & Lr2), 0)
If Application.WorksheetFunction.NetworkDays(Cells(1, j).Value, Cells(1, j).Value) = 1 And N = 0 Then C = C & " " & j - M - 1
Next j
For i = 3 To Lr
If Range("A" & i).Value <> "" Then R = R & " " & i - 3
Next i
Ra = Split(Right(R, Len(R) - 1))
Ca = Split(Right(C, Len(C) - 1))
ReDim S(Lr - 3, F - M - 1)
For i = LBound(Ra) To UBound(Ra)
    For j = LBound(Ca) To UBound(Ca)
        S(CLng(Ra(i)), CLng(Ca(j))) = Cells(CLng(Ra(i)) + 3, M).Value
    Next j
Next i

Cells(3, M + 1).Resize(Lr - 2, F - M).Value = S
End Sub
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i&, j&, C As String, R As String, S As Variant, Ca As Variant, Ra As Variant
Dim Lc&, Lr&, Lr2&, M&, F&, N&
Lr = Range("A" & Rows.Count).End(xlUp).Row
Lc = Cells(1, Columns.Count).End(xlToLeft).Column
Lr2 = Sheets("Data").Range("A" & Rows.Count).End(xlUp).Row
M = Application.Match(CLng(DateSerial(Year(Range("C1").Value), Month(Range("C1").Value) + 1, 0)) + 1, Rows(1), 0)
Resum1:
N = Lc + 1
N = Evaluate("=INDEX(" & Cells(1, M).Address & ":" & Cells(1, Lc).Address & ",MATCH(TRUE,COUNTIF(Data!A1:A" & Lr2 & "," & Cells(1, M).Address & ":" & Cells(1, Lc).Address & ")>0,0))")
N = Application.Match(N, Rows(1), 0)

Resum2:
        If Application.WorksheetFunction.NetworkDays(Cells(1, M).Value, Cells(1, M).Value) = 1 And N <> M Then
        Else
        M = M + 1
        If N < M Then GoTo Resum1
        GoTo Resum2
        End If
If Intersect(Target, Union(Range("A3:A" & Lr), Range(Cells(3, M), Cells(Lr, M)))) Is Nothing Then Exit Sub
F = Application.Match(CLng(DateSerial(Year(Cells(1, M).Value), Month(Cells(1, M).Value) + 1, 0)), Rows(1), 0)
For j = M + 1 To F
N = 0
N = Application.Match(Cells(1, j).Value, Sheets("Data").Range("A1:A" & Lr2), 0)
If Application.WorksheetFunction.NetworkDays(Cells(1, j).Value, Cells(1, j).Value) = 1 And N = 0 Then C = C & " " & j - M - 1
Next j
i = Target.Row
If Range("A" & i).Value <> "" Then R = R & " " & i - 3

Ra = Split(Right(R, Len(R) - 1))
Ca = Split(Right(C, Len(C) - 1))
ReDim S(F - M - 1)
    For j = LBound(Ca) To UBound(Ca)
        S(CLng(Ca(j))) = Cells(Target.Row, M).Value
    Next j
Range(Cells(Target.Row, M + 1), Cells(Target.Row, F)).Value = S

End Sub
 
Upvote 0
Hi maabadi,
The normal code is fine but the double click mode shows error.
 

Attachments

  • error844.png
    error844.png
    9.3 KB · Views: 4
  • error845.png
    error845.png
    13.2 KB · Views: 4
Upvote 0
Hi maabadi,
I combine the doubleclick and standard mode as one event. please see if there is any area to make it more neatly. Thanks.
VBA Code:
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
          If Sh.Name = "Data" Then Exit Sub
          Dim Lc&, Lr&, Lr2&, M&, F&, N&
          Lr = Range("A" & Rows.Count).End(xlUp).Row
          Lc = Cells(1, Columns.Count).End(xlToLeft).Column
          Lr2 = Sheets("Data").Range("A" & Rows.Count).End(xlUp).Row
        M = Application.Match(CLng(DateSerial(Year(Range("C1").Value), Month(Range("C1").Value) + 1, 0)) + 1, Rows(1), 0)
Resum1:
N = Lc + 1
N = Evaluate("=INDEX(" & Cells(1, M).Address & ":" & Cells(1, Lc).Address & ",MATCH(TRUE,COUNTIF(Data!A2:A" & Lr2 & "," & Cells(1, M).Address & ":" & Cells(1, Lc).Address & ")>0,0))")
N = Application.Match(N, Rows(1), 0)

Resum2:
        If Application.WorksheetFunction.NetworkDays(Cells(1, M).Value, Cells(1, M).Value) = 1 And N <> M Then
        Else
        M = M + 1
        If N < M Then GoTo Resum1
        GoTo Resum2
        End If

F = Application.Match(CLng(DateSerial(Year(Cells(1, M).Value), Month(Cells(1, M).Value) + 1, 0)), Rows(1), 0)
If Intersect(Target, Range(Cells(2, M), Cells(2, M))) Is Nothing Then Exit Sub             'Apply to Row 2 in Range
Cancel = True

Application.DisplayAlerts = False

For j = M + 1 To F
N = 0
N = Application.Match(Cells(1, j).Value, Sheets("Data").Range("A1:A" & Lr2), 0)

If Application.WorksheetFunction.NetworkDays(Cells(1, j).Value, Cells(1, j).Value) = 1 And N = 0 Then C = C & " " & j - M - 1
Next j

For i = 3 To Lr
If Range("A" & i).Value <> "" Then R = R & " " & i - 3
Next i

Ra = Split(Right(R, Len(R) - 1))
Ca = Split(Right(C, Len(C) - 1))
ReDim S(Lr - 3, F - M - 1)

For i = LBound(Ra) To UBound(Ra)
    For j = LBound(Ca) To UBound(Ca)
        Select Case Cells(CLng(Ra(i)) + 3, M).Value
               Case "D", "D1", "D2", "D3", "D4", "D5", "G", "K"
        S(CLng(Ra(i)), CLng(Ca(j))) = Cells(CLng(Ra(i)) + 3, M).Value
        End Select
    Next j
Next i

Cells(3, M + 1).Resize(Lr - 2, F - M).Value = S

Application.DisplayAlerts = True
End Sub
 
Upvote 0
The normal code is fine but the double click mode shows error.
You should add
VBA Code:
On Error Resume Next
After Dim lines such as Normal code.

Also Do same work fir mixed Code and then Test Both
 
Upvote 0
Hi maabadi,
How to add two more conditions not to copy the value in a row if
1. any cells NOT (ISEMPTY(CELL))
2. any cells with any interior colors other than RGB(255, 245, 230) (this is the weekend color)
(With image provided, I mean N3 and S3 should have no impact when run the marco.
I also find a function to search for cells with interior-colored but I do not know how to assemble it to your codes.
VBA Code:
Public Function HasColor(rg As Range, color As Long) As Boolean
  If rg.DisplayFormat.Interior.color = color Then
    HasColor = True
  ElseIf VBA.IsNull(rg.DisplayFormat.Interior.colorIndex) Then
    ' The color index is null so there is more than one color in the range
    Dim midrow&
    midrow = rg.Rows.Count \ 2
    If HasColor(rg.Resize(midrow), color) Then
      HasColor = True
    ElseIf HasColor(rg.Resize(rg.Rows.Count - midrow).Offset(midrow), color) Then
      HasColor = True
    End If
  End If
End Function
 

Attachments

  • 2conditionsnottocopy.png
    2conditionsnottocopy.png
    28.9 KB · Views: 4
Upvote 0
Rich (BB code):
1. any cells NOT (ISEMPTY(CELL))
At this situation if you change month the you hold filled cell Values. then code cannot add new values to them.
if you want solve it then add that fixed values specific color to change code based on.
I think you give wrong code for yellow color cell. you give me pink color RGB Code.
With formula I write with Green Color at the code change it to your yellow color code.
Also I add Select Case Method with Green Line and ' at the first of that lines. if you want it , I give structure within Code:
VBA Code:
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
    If Sh.Name = "Data" Then Exit Sub
    On Error Resume Next
    Dim i&, j&, C As String, R As String, S As Variant, Ca As Variant, Ra As Variant
    Dim Lc&, Lr&, Lr2&, M&, F&, N&
    Lr = Range("A" & Rows.Count).End(xlUp).Row
    Lc = Cells(1, Columns.Count).End(xlToLeft).Column
    Lr2 = Sheets("Data").Range("A" & Rows.Count).End(xlUp).Row
    M = Application.Match(CLng(DateSerial(Year(Range("C1").Value), Month(Range("C1").Value) + 1, 0)) + 1, Rows(1), 0)
Resum1:
    N = Lc + 1
    N = Evaluate("=INDEX(" & Cells(1, M).Address & ":" & Cells(1, Lc).Address & ",MATCH(TRUE,COUNTIF(Data!A1:A" & Lr2 & "," & Cells(1, M).Address & ":" & Cells(1, Lc).Address & ")>0,0))")
    N = Application.Match(N, Rows(1), 0)

Resum2:
    If Application.WorksheetFunction.NetworkDays(Cells(1, M).Value, Cells(1, M).Value) = 1 And N <> M Then
    Else
    M = M + 1
    If N < M Then GoTo Resum1
    GoTo Resum2
    End If


F = Application.Match(CLng(DateSerial(Year(Cells(1, M).Value), Month(Cells(1, M).Value) + 1, 0)), Rows(1), 0)
If Intersect(Target, Range(Cells(2, M), Cells(2, M))) Is Nothing Then Exit Sub             'Apply to Row 2 in Range
Cancel = True

Application.DisplayAlerts = False
ReDim Ar(3 To Lr, M + 1 To F)
For i = 3 To Lr
   
    For j = M + 1 To F
        If Range("A" & i).Value <> "" Then 'R = R & " " & i - 3
            N = 0
            N = Application.Match(Cells(1, j).Value, Sheets("Data").Range("A1:A" & Lr2), 0)
           
            If Application.WorksheetFunction.NetworkDays(Cells(1, j).Value, Cells(1, j).Value) = 1 And N = 0 Then
            'Find Long Value for RGB Color = Red + Green * 256 + Blue * 65536
                If Cells(i, j).Interior.Color = 15136255 Or Cells(i, j).Value <> "" Then
                    Ar(i, j) = Cells(i, j).Value
                Else
     ' if you want Select case add it here or remove ' at next lines and then delete first line after them
'                    Select Case Cells(i, M).Value
'                        Case "D", "D1", "D2", "D3", "D4", "D5", "G", "K"
'                            Ar(i, j) = Cells(i, M).Value
'                    End Select
                    Ar(i, j) = Cells(i, M).Value
                End If
            End If
        Else
            If Cells(i, j).Value <> "" Then Ar(i, j) = Cells(i, j).Value
        End If
    Next j
Next i

Cells(3, M + 1).Resize(Lr - 2, F - M).Value = Ar

Application.DisplayAlerts = True
End Sub
 
Upvote 0
Hi maabadi,
Before moving further to my latest request, I found the code in post 32 does not work correctly. It fills the holidays' column as well.
However the code using ISHOLWEEKEND function in Post 19 does the job properly.

AgentProposal_Roster0728_0829.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKAL
1MDateAttendance26-Sep27-Sep28-Sep29-Sep30-Sep1-Oct2-Oct3-Oct4-Oct5-Oct6-Oct7-Oct8-Oct9-Oct10-Oct11-Oct12-Oct13-Oct14-Oct15-Oct16-Oct17-Oct18-Oct19-Oct20-Oct21-Oct22-Oct23-Oct24-Oct25-Oct26-Oct27-Oct28-Oct29-Oct30-Oct31-Oct
2DateSummary(5)(4)(3)(2)(1)12345678910111213141516171819202122232425262728293031
3Mary KT:19 L:0 D:20 E:0 N:0GGGGGGGGGGGGGGGGGGGGGGGGG
4Jane LT:19 L:0 D:20 E:0 N:0DDDDDDDDDDDDDDDDDDDDDDDD
5George MT:19 L:0 D:20 E:0 N:0KKKKKKKKKKKKKKKKKKKK
6Bebe MT:19 L:0 D:20 E:0 N:0D4D4D4D4D4D4D4D4D4D4D4D4D4D4D4D4D4D4D4D4D4D4D4D4
7Apple MT:19 L:0 D:20 E:0 N:0D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3
8Kitty ST:19 L:0 D:0 E:0 N:4DDD NNNN
9Zita LT:19 L:0 D:0 E:3 N:0D3EEE
202110
Cells with Data Validation
CellAllowCriteria
A3:A9List=HelpAgent
H3:AL9List=ShiftcodeNew

VBA Code:
Sub FillNetworkDays22M32()
On Error Resume Next
Dim i&, j&, C As String, R As String, S As Variant, Ca As Variant, Ra As Variant
Dim Lc&, Lr&, Lr2&, M&, F&, N&
Lr = Range("A" & Rows.Count).End(xlUp).Row
Lc = Cells(1, Columns.Count).End(xlToLeft).Column
Lr2 = Sheets("Data").Range("A" & Rows.Count).End(xlUp).Row
M = Application.Match(CLng(DateSerial(Year(Range("C1").Value), Month(Range("C1").Value) + 1, 0)) + 1, Rows(1), 0)
Resum1:
N = Lc + 1
N = Evaluate("=INDEX(" & Cells(1, M).Address & ":" & Cells(1, Lc).Address & ",MATCH(TRUE,COUNTIF(Data!A1:A" & Lr2 & "," & Cells(1, M).Address & ":" & Cells(1, Lc).Address & ")>0,0))")
N = Application.Match(N, Rows(1), 0)

Resum2:
        If Application.WorksheetFunction.NetworkDays(Cells(1, M).Value, Cells(1, M).Value) = 1 And N <> M Then
        Else
        M = M + 1
        If N < M Then GoTo Resum1
        GoTo Resum2
        End If

F = Application.Match(CLng(DateSerial(Year(Cells(1, M).Value), Month(Cells(1, M).Value) + 1, 0)), Rows(1), 0)
For j = M + 1 To F
N = 0
N = Application.Match(Cells(1, j).Value, Sheets("Data").Range("A1:A" & Lr2), 0)
If Application.WorksheetFunction.NetworkDays(Cells(1, j).Value, Cells(1, j).Value) = 1 And N = 0 Then C = C & " " & j - M - 1
Next j
For i = 3 To Lr
If Range("A" & i).Value <> "" Then R = R & " " & i - 3
Next i
Ra = Split(Right(R, Len(R) - 1))
Ca = Split(Right(C, Len(C) - 1))
ReDim S(Lr - 3, F - M - 1)
For i = LBound(Ra) To UBound(Ra)
    For j = LBound(Ca) To UBound(Ca)
    Select Case Cells(CLng(Ra(i)) + 3, M).Value
               Case "D", "D1", "D2", "D3", "D4", "D5", "G", "K"
        S(CLng(Ra(i)), CLng(Ca(j))) = Cells(CLng(Ra(i)) + 3, M).Value
    End Select
    Next j
Next i

Cells(3, M + 1).Resize(Lr - 2, F - M).Value = S
End Sub
 
Upvote 0
I found the code in post 32 does not work correctly. It fills the holidays' column as well.
I see Code working Correctly. this code only write the cells belong to month with 1 day within range. here is October. then only cells has in October ranges (here column H and later) Affected. and column C to G (with previous Month Data) not affected here and maintain previous data.
 
Upvote 0
I see Code working Correctly. this code only write the cells belong to month with 1 day within range. here is October. then only cells has in October ranges (here column H and later) Affected. and column C to G (with previous Month Data) not affected here and maintain previous data.
Hi maabadi,
I know it will have no impact in the previous month columns but it can't find which date is holiday of the month. See my screenshot to show you that Feb 9 is holiday but the marco copies the value to that column as well.
Please help.
 

Attachments

  • feberror.png
    feberror.png
    37.5 KB · Views: 4
Upvote 0

Forum statistics

Threads
1,215,480
Messages
6,125,047
Members
449,206
Latest member
Healthydogs

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