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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,357
Office Version
  1. 365
Platform
  1. Windows
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
 

jfalcone1

Board Regular
Joined
Jul 13, 2007
Messages
55
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.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,357
Office Version
  1. 365
Platform
  1. Windows
Sorry you've lost me there.:eek:

I don't see how that code would do that.
 

jfalcone1

Board Regular
Joined
Jul 13, 2007
Messages
55
: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:
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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.
 

jfalcone1

Board Regular
Joined
Jul 13, 2007
Messages
55
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.
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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?
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Scroll up and see your sample output, as you see it shows a formula but no data.
 

Forum statistics

Threads
1,181,648
Messages
5,931,213
Members
436,784
Latest member
amuljono

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
Top