Macro Edit - Move row data (between columns A:J) to new sheet, based upon cell value.

BETHROB1993

New Member
Joined
May 21, 2018
Messages
8
I have been using the macro below to move a row of data to a new sheet, if "Done" is selected in column J. However, I only want it to move the data between columns A:J, rather than the entire row. Is someone able to help me edit the below macro, or perhaps offer a new one that will offer the solution?
Completely new to macros :O

Sub Cheezy()
'Updated by Kutools for Excel 2017/8/28
Dim xRg As Range
Dim xCell As Range
Dim I As Long
Dim J As Long
Dim K 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("J1:J" & 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
 
Column J is column 10

I'm using the column number.

It needs a column number not a column letter.
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Code:
Sub Filter_Me_Please_New()'Modified 5/22/18 8:10 AM EDT
Dim Lastrow As Long
Dim Lastrowa As Long
Dim c As [COLOR=#0000ff][B]Long[/B][/COLOR]
Dim s As Variant
Dim CopyFrom As String
Dim CopyTo As String
CopyFrom = "CamillaHouse" 'Modify as needed
CopyTo = "Completed Actions"  'Modify as needed
c = [B][COLOR=#ff0000]"10"[/COLOR][/B] ' Column Number Modify this to your need
In reply to post #10 , c has been declared as type long, this means it can only store whole numbers.
Rich (BB code):
c = 10
works because 10 is represented numerically
Rich (BB code):
c = "10"
doesn't work because 10 is represented by a string (inside speachmarks)
As per post #11
Column J is column 10
I'm using the column number.
It needs a column number not a column letter.
It needs a numerical value, not a string value, hence "10" isn't valid.
 
Upvote 0

Forum statistics

Threads
1,216,088
Messages
6,128,744
Members
449,466
Latest member
Peter Juhnke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top