Log in  \/ 
x
or
x
x
Register  \/ 
x

or

unanswered Need help with Excel code editing

More
3 months 4 weeks ago #1962 by aliza.phillips
Need help with Excel code editing was created by aliza.phillips
I need help! I am trying to create a worksheet to help at work except I am not really computer literate.  I used an existing code that was magical except for a minor tweek that I cannot seem to edit successfully.  I need to move data from a selection on Sheet 1 based on a value to Sheet 2.  I need the code to delete within a specific range and not the entire row. I have other data on the row that I don't want deleted.  I have named the range on Sheet 1 to "RESTORATION" (=Sheet1!$A$15:$F$54) hoping that I could incorporate the name within the code. I don't know how to change the code to move and delete information within named range "RESTORATION".  This is the original code that I need to edit:
Sub
Cheezy()
'Updated by Kutools for Excel 2017/8/28
    
Dim
xRg 
As
Range
    
Dim
xCell 
As
Range
    
Dim
As
Long
    
Dim
As
Long
    
Dim
As
Long
    
I = Worksheets(
"Sheet1"
).UsedRange.Rows.Count
    
J = Worksheets(
"Sheet2"
).UsedRange.Rows.Count
    
If
J = 1 
Then
       
If
Application.WorksheetFunction.CountA(Worksheets(
"Sheet2"
).UsedRange) = 0 
Then
J = 0
    
End
If
    
Set
xRg = Worksheets(
"Sheet1"
).Range(
"C1:C"
& I)
    
On
Error
Resume
Next
    
Application.ScreenUpdating = 
False
    
For
K = 1 
To
xRg.Count
        
If
CStr
(xRg(K).Value) = 
"Done"
Then
            
xRg(K).EntireRow.Copy Destination:=Worksheets(
"Sheet2"
).Range(
"A"
& J + 1)
            
xRg(K).EntireRow.Delete
            
If
CStr
(xRg(K).Value) = 
"Done"
Then
                
K = K - 1
            
End
If
            
J = J + 1
        
End
If
    
Next
    
Application.ScreenUpdating = 
True
End
Sub

Please Log in or Create an account to join the conversation.

Moderators: jaychivoExcelfansqiuhongkun