VBA Date Range - Overflow problem

JessM

New Member
Joined
Aug 13, 2017
Messages
2
Hey all,

Wondering if anyone can help me.

Basically I have a number of sheets in a workbook that I need my VBA to search through for any rows that contain a date within a range, copy that information and paste it into a specified sheet. I have it working for a single date using VBA but cannot work out how to get it to work a range specified by the user (start and end dates).

Here is a pastebin for my code: [VisualBasic] VBA Overflow Daterange - Pastebin.com

I am getting an overflow error on line "nxtRw = nxtRw + .SpecialCells(xlCellTypeVisible).Count - 1"
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hia & welcome to the board
That row is adding up all the visible cells rather than the rows. try something like
Code:
NxtRw = NxtRw + Sheets(shtNum).cells.Find("*", after:=Sheets(shtNum).Range("A1"), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row.Offset(1)
 
Upvote 0
Hi. There are a couple of problems that are initially apparent. You are qualifying your ranges with sheet names most of the time but didnt in this block:

Code:
If Sheets("GRN-Date Search").Range("J3") = "" Or Sheets("GRN-Date Search").Range("J4") = "" Then
    MsgBox "You must enter a date range to search"
    Sheets("GRN-Date Search").Select
    Range("J3").Select
    Exit Sub
End If

Then for nxtRw id go:

Code:
nxtRw = Sheets("GRN-Date Search").Cells(Rows.Count, 1).End(xlUp).Row + 1
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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