Using a cell value from main worksheet in macro formula

mpham168

New Member
Joined
Jul 21, 2011
Messages
7
Hi all,

I'm quite new to this so please don't flame me if I've posted in the wrong area.

I'm seeking some advice/help with regards to the below

Basically I'm trying to have the macro autofilter specific date ranges determined by a value (1,2,3,4,5 etc...) from the main worksheet (for this post I have called it MACRO).

If anyone has any ideas could they please let me know?

Dim x As String

Dim dDate As Date
Dim strDate As String

Dim lDate As Long
dDate = DateSerial(Year(Date), Month(Date), Day(Date))
lDate = dDate

x = not sure about here but something like ? Sheets(MACRO).Range("A1").Value
Range("A1").Select
Sheets("WORKING SHEET").Select
Rows("1:1").Select
ActiveSheet.Range("$A$1:$AP$1912").AutoFilter Field:=10, Criteria1:=">" & lDate + x, Operator:=xlAnd
Rows("2:2").Select

Any help would be greatly appreciated!

Thanks in advance

mpham168
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Thanks for pointing that out, however, I did try this earlier and I am afraid I simply forgot to use quotation marks in my post.

Currently I am receiving a break in the below

Dim dDate As Date

Dim strDate As String

Dim lDate As Long

Dim x As String

x = Sheets("MACRO").Range("I7").Value

Range("A1").Select
Sheets("WORKING SHEET").Select
Rows("1:1").Select
ActiveSheet.Range("$A$1:$AP$1912").AutoFilter Field:=10, Criteria1:=">" & lDate + x, Operator:=xlAnd

I am not sure how to proceed - I found another question on the forum relating to extracting a value from a table but that did not help address my problem.
 
Upvote 0
Are you getting an error?
If so, what is it?
[my copy doesn't error]

Two things:

if Sheets("MACRO").Range("I7") is numeric then x should be declared as integer (based on previous post)

Column 10 is Numeric/Date format?
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,682
Members
452,937
Latest member
Bhg1984

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