Macro runs into "object required" error, please debug.

AlexCHI

New Member
Joined
Sep 28, 2017
Messages
19
Greetings All,

I am unfamiliar with VBA so reaching out to anyone who can help me debug why the macro named "Sheet2.ShowMembership" runs into "Object required" error message when fired?

The macro in question basically turns column A & B (last name & first name) into bolded text with yellow fill when a person reaches a consecutive 6-month attendance (or as written in the VBA, 26 consecutive attendance indicated by either "AM", "PM", or "AM & PM" from column T:NT.

If I changed the "Sub ShowMembership()" to "Private Sub Worksheet_Change(ByVal Target As Range)" then it works beautifully by itself but I have to sacrifice the other VBA with the same sub which is date and day input in B3 and B5.

Ideally is there a way to modify the last two VBAs in the attached file so they can coexist as Worksheet_Change? If not, please teach me how to correct the ShowMembership macro.

Please access the file here:
https://drive.google.com/open?id=1KdGqbExqYBIXcLiDkVhyGrPkOB-cFC9V

Thank you in advance for your time and help!
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi,
I think you have kind of answered your own question.
Worksheet_Change event has a range argument "Target" which you have included in your procedure but not passed this to it when called.

Try these changes

ShowMembership code add the argument

Rich (BB code):
Sub ShowMembership(ByVal Target As Range)


From where ever required in the worksheet_change event

Rich (BB code):
ShowMembership Target

This should now pass the range to your code.

I also noticed a typo with your declaration

You have declared
Dim xAdress As String

but in the code you use

xAddress = "K:R"

you can avoid this by placing Option Explicit at very TOP of the module / code page where compiler will report missing variables.

Hope Helpful

Dave
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

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