reading by row depending on a number range

rfletcher35

Active Member
Joined
Jul 20, 2011
Messages
300
Office Version
  1. 365
Platform
  1. Windows
Help Please!!

I have columns W - AG starting at row 5 onwards that contains my data.
Column W has numbers and these are formatted as numbers.
The sheet the data is on is called "MPR Data"

I want VBA code that will start at row 5 and work down column W selecting only rows that this column has the numbers between 358-364
I need it to select the rows within this parameter and copy cells on that row from W-AG
Then I need it to paste values on another sheet called Results Sheet starting from Column AB Row 5
I need it to do this until the last row.

I think I have explained it through but if you need more info then please ask I really need this!!!

Thanks

Fletch
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Give this macro a try...
Code:
[table="width: 500"]
[tr]
	[td]Sub MoveRowsForNumbers358thru364()
  Dim LastRow As Long, Addr As String
  With Sheets("MPR Data")
    LastRow = .Cells(Rows.Count, "W").End(xlUp).Row
    Addr = "'MPR Data'!W5:W" & LastRow
    With .Range(Addr)
      .Formula = Evaluate(Replace("IF((@>=358)*(@<=364),IF(@="""","""",@),""=""&@)", "@", Addr))
      Intersect(.Parent.Columns("W:AG"), .SpecialCells(xlConstants).EntireRow).Copy Sheets("Results Sheet").Range("AB5")
      .Replace "=", "", xlPart
    End With
  End With
End Sub[/td]
[/tr]
[/table]
 
Upvote 0
=1224YESNO ABSENCEYESJulyxxStewart Aalten727006
=121NONO ABSENCEYESJuly
=1283YESAben AeneasNOMayxxAnita Abbott577162
=1582YESNO ABSENCEYESJulyxxMichael Hampton725468
=1384YESNO ABSENCEYESFebruaryxxWayne Adams725626
=406YESNO ABSENCEYESOctoberxxStanley Nosella725444
=1378YESNO ABSENCEYESFebruaryxxFahd Ahmad728059
=852YESNO ABSENCEYESJulyxxZulfikar Ahmed725696
=490YESWaqar AhmedNOJulyxxAniel Ahmed727752
=975YESNO ABSENCEYESMarchxxRosjen Ahmed727914

<colgroup><col style="width:48pt" width="64" span="11"> </colgroup><tbody>
</tbody>


Think that is nearly working, the above is what that code produces. until it fails but I think it fails because in my rows there are blanks.

Is there a way of telling it to ignore blanks and say run to row 4000 where I know there should be no data?

Thanks for you help

Fletch
 
Upvote 0
Hi,

I have just thought of a possible alternative method. Is there any way within VBA of filtering within those number ranges. That way I can just use code to copy that range of data it produces to copy which may or may not be easier, what do you think...?

So filter 358-364 on column W possibly?


Fletch
 
Upvote 0
Hi,

This is what I mean't by last message but it just doesn't seem to be working

ActiveSheet.Range("$V$4:$AD$3150").AutoFilter Field:=1, Criteria1:=">=358", Operator:=xlFilterValues, Criteria2:="<364", Operator:=xlFilterValues

It filters on W but doesn't come up with anything even though I know there is a 359 in there?
 
Upvote 0
Hi

Thanks for all your help a combination of both worked in the end.

Many thanks

Fletch
 
Upvote 0

Forum statistics

Threads
1,214,423
Messages
6,119,398
Members
448,892
Latest member
amjad24

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