HELP!- VBA Code Not Work when moving rows from 1 sheet to another

baba7vb

New Member
Joined
Jun 7, 2020
Messages
6
Office Version
  1. 2013
Platform
  1. Windows
Hello All,
The below code is not working when I change the criteria(line 17) from a number to a text. Can anyone help?
Do i need to do anything to Line 11?
I want to pick up any rows in which Column T contains the word DSM and move a range of columns(Line 20- (RawData) to columns A-E in Sheet D.


VBA Code:
[LIST=1]
[*]Sub DMSL()
[*]

[*] Dim xRg As Range
[*]    Dim xCell As Range
[*]    Dim i As Long
[*]    Dim J As Long
[*]    Dim K As Long
[*]    i = Worksheets("RawData").UsedRange.Rows.Count
[*]    J = Worksheets("D").UsedRange.Rows.Count
[*]    If J = 1 Then
[*]    If Application.WorksheetFunction.CountA(Worksheets("D").UsedRange) = "0" Then J = 0
[*]    End If
[*]    Set xRg = Worksheets("RawData").Range("T1:T" & i)
[*]    On Error Resume Next
[*]    Application.ScreenUpdating = False
[*]    For K = 1 To xRg.Count
[*]        If CStr(xRg(K).value) = "DSM" Then
[*]         J = J + 1
[*]         With Worksheets("RawData")
[*]         Intersect(.Rows(xRg(K).Row), .Range("D5:D577,F5:F577,J5:L577,W5:W577")).Copy Destination:=Worksheets("D").Range("A" & J)
[*]        End With
[*]       
[*]        End If
[*]    Next
[*]    Application.ScreenUpdating = True
[/LIST]
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hello
Thanks- i have managed to get it to work eventually.
Will publish code tomorrow
 
Upvote 0

Forum statistics

Threads
1,223,727
Messages
6,174,144
Members
452,547
Latest member
Schilling

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