Hello Experts,
Need a little help. Main aim is to use a "for loop" for sheet 1 for copying rows to sheet 2 while the condition met but failed to do so.
Here The condition is, If E1 Cell will find value "A" the whole row from A1 to AH1 will be copied to Sheet 2 row (A3 to AH3) and this is how it continues till E100 cell. I believe the code is ok but need to run a loop which I constantly failed.
Need a little help. Main aim is to use a "for loop" for sheet 1 for copying rows to sheet 2 while the condition met but failed to do so.
Here The condition is, If E1 Cell will find value "A" the whole row from A1 to AH1 will be copied to Sheet 2 row (A3 to AH3) and this is how it continues till E100 cell. I believe the code is ok but need to run a loop which I constantly failed.
VBA Code:
Public Sub CopyPaste()
Dim wbNew As Workbook
Dim strFolder, val
val = WeekdayName(Weekday(Now))
If Worksheets("Sheet1").Range("E1") = "A" Then
Worksheets("Sheet1").Range("A1:AH1").Copy Destination:=Worksheets("Sheet2").Range("A3")
Worksheets("Sheet2").Copy
MsgBox "Your Workbook has saved as Worksheet-" & FormatDateTime(Now, vbShortDate)
Set wbNew = ActiveWorkbook
If Len(Dir("E:VA\" & Day(Date) & "-" & MonthName(Month(Date), True) & "-" & Year(Date), vbDirectory)) = 0 Then
MkDir "E:VA\" & Day(Date) & "-" & MonthName(Month(Date), True) & "-" & Year(Date)
End If
wbNew.SaveAs ("C:\NEW\" & Format(Now(), "DD-MMM-YYYY") & "\NEW-WorkSheet- " & "Sheet2" & ".xls")
End Sub
Last edited by a moderator: