Run-time error '424': Object required, email on button click with selected cell values

wigi

Well-known Member
Joined
Jul 10, 2006
Messages
7,944
And where in the code do you fill that variable called Chkbx ? :)
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

mikura

New Member
Joined
Dec 28, 2013
Messages
11
I included "Dim chkbx As CheckBox" but now debugger is giving a message "Run-time error '91' :Object variable or block variable not set" and highlighting "If chkbx.Value = 1 Then". :confused:
 

wigi

Well-known Member
Joined
Jul 10, 2006
Messages
7,944
Declaring is not enough. With declaring, your reserve a little bit of memory for that variable.
But you do not fill that variable. You do not assign that variable a valid checkbox. So it's null and you cannot work with it in your code (it gives an error because it's not assigned a checkbox object).
 

mikura

New Member
Joined
Dec 28, 2013
Messages
11
Ok. Now I modified the code with a "for each" function
Dim counter As IntegerDim strSku As Long


Dim Mail As New Message
Dim Config As Configuration
Set Config = Mail.Configuration


For Each chkbx In ActiveSheet.CheckBoxes
If chkbx.Value = 1 Then
counter = 1
For r = 1 To counter
If Cells(r, 1).Top = chkbx.Top Then
counter = counter + 1

strSku = Cells(Target.row, "B").Value & " (" & Cells(Target.row, "A").Value & "), "
Exit For
End If

Next r
End If
Next
And I tried to send "strsku" in the body of the email. But I received just "0".
 

wigi

Well-known Member
Joined
Jul 10, 2006
Messages
7,944
Your counter variable is 1, so your inner loop will only be done for r = 1.
Is that correct?
 

mikura

New Member
Joined
Dec 28, 2013
Messages
11
Yes you are right.

I modified my for loop by "For r = 1 To Rows.Count". Now it is again showing Run-time error '424' and highlighting "strSku = Cells(Target.row, "B").Value & " (" & Cells(Target.row, "A").Value & "), ""
 

wigi

Well-known Member
Joined
Jul 10, 2006
Messages
7,944
Mikura

And where do you define / fill the variable Target?

Again, you cannot use variables if you do not fill them...

Man, this is getting frustrated...
 

Forum statistics

Threads
1,089,548
Messages
5,408,890
Members
403,240
Latest member
AlenKovacevic

This Week's Hot Topics

  • help please
    SORRY NOT ANY GOOD AT EXCEL SO HELP WOULD BE MUCH APPRECIATED this formula is in a sheet called ignore...
  • two formulas needed
    Hello, I'll try my best to explain this: First formula needed in Sheet1 cell A2: If Sheet1 cell B2 = Sheet2 cell B2 then return a 1. If not then...
  • Dynamic Counts
    Good afternoon, we are tidying up some data & the data seems to be growing quicker than we are tidying it up! What we confirm (by reviewing it...
  • Help Excel formula eliminate duplicate values and keep only 2 identical rows.
    as picture below column A has a duplicate value. but the values are not the same as the rule. sometimes 4 rows, sometimes 10 rows or 7 or 9...
  • Macro Compile Error Sub or Function not defined
    Hello, I am trying to run macros from a validation list, all macros have been created and run perfectly on there own but I'm getting a compile...
  • Last row combined with Current Region VBA
    I'm generally happy finding the last row of data through something like Lastrow = Cells(Rows.Count, "D").End(xlUp) but I don't always receive data...
Top