Drumin_Phreak
New Member
- Joined
- Oct 10, 2016
- Messages
- 25
Hello,
I'm new to VBA. my issue is this: If c7=c6 then d7,e7,f7, as well as p7:u7 (notice they are not consecutive) should auto fill with the values in their respective columns from the row above (row 6).
I have a code, but if I include "If IsEmpty(ActiveCell.Offset(i, i).Value) = False Then"
I find that it stops when I get passed g7 (as the value above it is blank). However, if I don't use it, the macro runs until it errors out.
Also the missing rows (the ones not mentioned here) are locked.
So the goal here is to Auto copy the above values in their respective columns if a condition is met in the ("C") column of the active cell's row.
Also, the copy effect will run until the last column in the row is reached ("U") and will not be interrupted if it encounters a locked cell.
Here is the code below
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myRng As Range
Set myRng = Range("now")
i = -1
Z = 1
If Intersect(Target, Range("now")) Is Nothing Then
ElseIf ActiveCell.Offset(0, i).Value = ActiveCell.Offset(i, i).Value Then
For Each x In myRng
If IsEmpty(ActiveCell.Offset(i, i).Value) = False Then
ActiveCell.Value = ActiveCell.Offset(i, 0).Value
ActiveCell.Offset(0, Z).Select
Else
Exit Sub
End If
Next x
End If
End Sub
I thank you very much for taking the time to listen to my issues, and look forward to your responses, and learning all I can in the process.
I'm new to VBA. my issue is this: If c7=c6 then d7,e7,f7, as well as p7:u7 (notice they are not consecutive) should auto fill with the values in their respective columns from the row above (row 6).
I have a code, but if I include "If IsEmpty(ActiveCell.Offset(i, i).Value) = False Then"
I find that it stops when I get passed g7 (as the value above it is blank). However, if I don't use it, the macro runs until it errors out.
Also the missing rows (the ones not mentioned here) are locked.
So the goal here is to Auto copy the above values in their respective columns if a condition is met in the ("C") column of the active cell's row.
Also, the copy effect will run until the last column in the row is reached ("U") and will not be interrupted if it encounters a locked cell.
Here is the code below
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myRng As Range
Set myRng = Range("now")
i = -1
Z = 1
If Intersect(Target, Range("now")) Is Nothing Then
ElseIf ActiveCell.Offset(0, i).Value = ActiveCell.Offset(i, i).Value Then
For Each x In myRng
If IsEmpty(ActiveCell.Offset(i, i).Value) = False Then
ActiveCell.Value = ActiveCell.Offset(i, 0).Value
ActiveCell.Offset(0, Z).Select
Else
Exit Sub
End If
Next x
End If
End Sub
I thank you very much for taking the time to listen to my issues, and look forward to your responses, and learning all I can in the process.