snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
I have a problem with copy data from multiple sheets base on current month.for example this month is Oct so if the month is Oct copy row contain that month to Sheet Main.
But my code not working fine
'Other code
For i = lr To 2 Step -1
On Error Resume Next
If IsDate(.Range("b" & i).Value) Then
If Month(.Range("b" & i).Value) = Month(Date) And Year(.Range("b" & i).Value) = Year(Date) Then
.Range("b" & i & ":g" & i).Copy Destination:=sh.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0)
sh.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Value = .Name
sh.Columns("f:f").EntireColumn.Hidden = True
End If
End If
On Error GoTo 0
Next i
'Other code