Hello all,
<tbody>
</tbody>
The problem with the code below is it excutes the output for all the cells without validating the condition in column E.
Any help to rectify this problem will be appreciated.
I only want the output for cells that have the validation as y
I have this code in VBA as follows
Sub validate()
For Each c In Range("E1:E20")
If c.Value = "y" Then Macro1
Next c
End Sub
Sub Macro1()
'
' Macro1 Macro
'
Dim rngCopy() As Variant
Dim rngPaste As Range
Dim Heading As Variant
Dim Cell As Range
Dim r As Integer
Heading = Array("Schedule", "Details", "Impact", "Verification")
r = 0
For Each Cell In Sheets(1).Range("A2", Sheets(1).Range("A" & Rows.Count).End(xlUp))
rngCopy() = Sheets(1).Range(Cell, Cell.Offset(0, 4)).Value
Set rngPaste = Sheets(2).Range("B" & 2 + r).Resize(4, 1)
rngPaste = Application.Transpose(rngCopy)
Sheets(2).Range("A" & 2 + r & ":A" & 5 + r).Value = Application.Transpose(Heading)
r = r + 5
Next Cell
End Sub
Schedule | Details | Impact | Verification | validation |
a | 1 | @ | one | y |
b | 2 | # | two | y |
c | 3 | $ | three | n |
d | 4 | % | four | n |
<tbody>
</tbody>
The problem with the code below is it excutes the output for all the cells without validating the condition in column E.
Any help to rectify this problem will be appreciated.
I only want the output for cells that have the validation as y
I have this code in VBA as follows
Sub validate()
For Each c In Range("E1:E20")
If c.Value = "y" Then Macro1
Next c
End Sub
Sub Macro1()
'
' Macro1 Macro
'
Dim rngCopy() As Variant
Dim rngPaste As Range
Dim Heading As Variant
Dim Cell As Range
Dim r As Integer
Heading = Array("Schedule", "Details", "Impact", "Verification")
r = 0
For Each Cell In Sheets(1).Range("A2", Sheets(1).Range("A" & Rows.Count).End(xlUp))
rngCopy() = Sheets(1).Range(Cell, Cell.Offset(0, 4)).Value
Set rngPaste = Sheets(2).Range("B" & 2 + r).Resize(4, 1)
rngPaste = Application.Transpose(rngCopy)
Sheets(2).Range("A" & 2 + r & ":A" & 5 + r).Value = Application.Transpose(Heading)
r = r + 5
Next Cell
End Sub