just a vb line i need correct parentheses

fenster

Board Regular
Joined
Nov 11, 2002
Messages
98
finish = "<=" & Sheet4.Cells.Range("$D$4").Value & DateSerial(Year(Date), Month(Date) + 1, 1)


the above line is causing me all kinds of bother with the autofilter.

its a long story but heres what i need:

these lines of code in correct parentheses:

finish = "<=" & Sheet4.Cells.Range("$D$4").Value + DateSerial(Year(Date)

finish = "<=" & Sheet4.Cells.Range("$D$4").Value + Month(Date) + 1, 1)

can anyone help -

davie..

btw
thanks for looking ;)
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
D4 is a cell with a start date.

i was talking all yesterday to jmiskey..

http://www.mrexcel.com/board2/viewtopic.php?t=50971&postdays=0&postorder=asc&start=0

the autofilter kept switching dd/mm to mm/dd but by using the line i posted the format is dd/mm only problem is that there are two dates being generated from this line..

so if i can hack it up and just use the part that is formatting date correctly and omit the second date ten im fixed!

the full code im usig is in the other thread...

thanks
 
Upvote 0
Andrew,

Thanks for the pick-up. We were working on it a while yesterday, and we figured out that the problem was with the dates. The problem is that I am in the U.S., so I couldn't recreate the situation, so I couldn't develop and test possible solutions. I thought that maybe changing the dates to strings might work(?). I see the Long Integer solution worked.
 
Upvote 0
is there a difficulty in the line of code i posted being split??

im 99% there with that line...in the meantime im trying to use the code from the other thread..
 
Upvote 0
Fenster,

How's it going? It looks like Andrew handled the same situation and came up with a solution (see his last response in the referenced thread).

Try this:

Code:
Sub Macro9() 

Dim StartDate
Dim EndDate

StartDate = CLng(Range("D4").Value)
EndDate = CLng(Range("G4").Value)

Sheets("Voucher").Select 
Columns("A:A").Select 
Range("A7:A2100").Select 
Selection.AutoFilter 
Selection.AutoFilter Field:=1, Criteria1:=">=" & StartDate, Operator:=xlAnd _ 
, Criteria2:="<=" & EndDate 
'Selection.PrintOut Copies:=1, Collate:=True 

End Sub

EDIT: See above
 
Upvote 0
See my edit above. Cut and paste the code and give it a go!
 
Upvote 0

Forum statistics

Threads
1,221,701
Messages
6,161,381
Members
451,700
Latest member
Eccymarge

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