Syntax Error

jfalcone1

Board Regular
Joined
Jul 13, 2007
Messages
55
What is wrong with my syntax? :x


Sub Button84_Click()
With Sheets("Database")
ActiveSheet.Unprotect "COMPS"
If .Selection.AutoFilter Field:=10, Criteria1:="X" Then .Range("C6:J6").Copy
End If
ActiveSheet.Protect "COMPS"
End With

End Sub


someone must know?.?.?.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
You can't use Selection like that.

It's not a worksheet property, also you are trying to unprotect the ActiveSheet not the Database worksheet.

Now that sheet might be the active sheet but it's not guaranteed.

I can't really help with the Selection problem, as I don't actually know what is selected or what you want to filter.

But this is how you would do the unprotect/protect.
Code:
With Sheets("Database")
     .Unprotect "COMPS"
     ' other code
     .Protect "COMPS"
End With
 
Upvote 0
Im trying to say that If the cell lets say a7, is sorted using criteria 'X' then the following range should copy to the given destination cell.
 
Upvote 0
Sorry you've lost me there.:eek:

I don't see how that code would do that.
 
Upvote 0
:oops:

yea I think thats what I am looking for, something that WOULD do that. Its a really far fetched idea, i just dont have the skills.


So there is no way to create a condition based on an operation in autofilter? If not, I will move on to another idea. :oops:
 
Upvote 0
You can't use the AutoFilter like you have, but it's still not clear to me what you are trying to do. It looks like you want C6:J6 copied if there is any X in whatever column you are looking for it to be in, please specify. If you only want this one specific range copied, why do you need AutoFilter at all? But then you mention A7, which certainly is not in Field10 (where did that come from?). Why are you using Selection? Is there a specific range you want to look in?
Please provide specific details about what you are trying to accomplish exactly, examples if you can, what the range you are looking in, etc.
 
Upvote 0
You can't use the AutoFilter like you have, but it's still not clear to me what you are trying to do. It looks like you want C6:J6 copied if there is any X in whatever column you are looking for it to be in, please specify.

What I have is a database defined in rows, that is sorted using a series of variables in columns. The variables are defined in the column headers whose range is from c6:ae6. If these various criteria are applicable to a specific row, an 'X' is used to designate it in the autofilter.

Edit: MOD: html deleted. To the OP - only post representative samples of your data, not dozens of columns / rows as it tends to mess with the display.
 
Upvote 0
There is no output in your output sample sheet.

An X based in what column? What kind of data are you trying to return? From where?
 
Upvote 0
Scroll up and see your sample output, as you see it shows a formula but no data.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

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