I am using 2 for statements, 1 nested within another. What I am having issues with is when I exit the second statement and return to the first one I am unable to have the second statement go to the next cell, instead it keeps repeating itself.
for example:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r&, c&, cel As Range
Dim r3&, c3&, cel3 As Range
Dim ri As Range
Dim CurrentSheet As String
Dim CurrentCell As String
CurrentSheet = ActiveSheet.Name
Application.ScreenUpdating = False
ActiveCell.Offset(-1, 0).Select
CurrentCell = ActiveCell.Address
r = ActiveCell.Row
For c = 26 To 31
Sheets(CurrentSheet).Select
Set cel = Cells(r, c)
cel.Select
Selection.Copy
Cells(Target.Row, "B").Select
Set ri = ActiveCell
Sheets("Checklist").Select
'For c2 = 1 To 31
Sheets("Checklist").Cells.Find(What:=ri.Value, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Select
For c3 = 25 To 30
Sheets("checklist").Select
r3 = Selection.Row
Set cel3 = Sheets("checklist").Cells(r3, c3)
cel3.Select
Selection.PasteSpecial xlPasteValues
Sheets(CurrentSheet).Select
'Range(CurrentCell).Select
'ActiveCell.Offset(0, 1).Select
'CurrentCell = ActiveCell.Address
'Exit For
Next
'Next
Next
Range(CurrentCell).Select
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
Keep in mind that is not my actual code but rather an example of how it is structured. Instead of looping through columns 5 - 9 it just keeps selecting column 5.
Essentially what I am trying to do with the code is when a cell is changed on Sheet1 I want it to loop through each cell in that row (predetermined number of columns) and copy the cell value to sheet2 (Checklist for purposes of the code) and paste in a corresponding cell. The code also looks up and an identifier on sheet1 to find the correct row in sheet2.
Here is a link to the example file Checklist Example
For c 5 to 9? should not even compile, should beFor c = 5 to 9. Also, where do you define and setc3? Maybe it's better you describe better what you are trying to achieve, so we can offer you the right solution for your needs (instead of correcting this code's errors)Worksheet_Changeevent ? what should the code do?ri.Valueare you trying to find inSheets("Checklist")? is it theTarget(ActiveCellwhich is pressed, orCells(Target.Row, "B"), the cell in the same row at Column "B" ? Are you trying to findEmp#? orRI Name?