Same Macro, different issue, cannot turn off filtered column

sspatriots

Well-known Member
Joined
Nov 22, 2011
Messages
585
Office Version
  1. 365
Platform
  1. Windows
I've been getting this code closer to what I need it to do, however, after it runs and puts a snapshot of a filtered selection in an e-mail, I cannot get it to return to the workbook and turn off the filtered item. It stays selected and highlighted. The code right now is shown below:



Sub SendEmailJohnDoe()



Set OutApp = CreateObject("Outlook.Application")

Set OutMail = OutApp.CreateItem(0)



JohnDoe



On Error Resume Next

With OutMail

.To = "JohnDoe@gmail.com"

.CC = "JaneDoe@gmail.com"

.Subject = "Update to your PO(s)"

.Body = ""

.Display

End With



SendKeys "^v"

On Error GoTo 0



Set OutMail = Nothing

Set OutApp = Nothing







End Sub



Sub JohnDoe()

'

' JHM Macro

'



'

Sheets("LogDetails").Select



ActiveSheet.Range("$A$1:$O$100").AutoFilter Field:=10, Criteria1:="JHM"

Range("G1:O20").Select

Selection.Copy

End Sub



I need this to run, let me send the e-mail (that part works), then return to the spreadsheet and turn the filter off for "JHM". The Range is an issue too because I only want the range to the end of the filtered cells that go into the e-mail. Years ago, I had code that did all this, but I'm sure that is still with that employer. So starting over.


1646862831069.png
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
???
VBA Code:
  If ActiveSheet.AutoFilterMode Then
     ActiveSheet.AutoFilterMode = False
  End If

Edit: ActiveSheet.AutoFilterMode = False
is all you probably need.
 
Upvote 0
???
VBA Code:
  If ActiveSheet.AutoFilterMode Then
     ActiveSheet.AutoFilterMode = False
  End If

Edit: ActiveSheet.AutoFilterMode = False
is all you probably need.
I believe I tried that and what happened was the cells I was copying into the e-mail would not show up in the e-mail.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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