Nothing

miami2k

Board Regular
Joined
Nov 1, 2017
Messages
58
I'm always having problems with sheets activation. In this case my range returns as nothing. The comand is activated in a combo placed in a different sheet of the same file.
In any of the set options the result for my i range is "Nothing" and the error if I move on top of the line is Error 1004 “Application-defined or Object-defined error”

Thank you

Private Sub CMBCliente_DropButt*******()


Dim i As Range
Dim Clienti As Worksheet
Dim lrow As Long
Set Clienti = Sheets("Clienti")

With Sheets("Clienti")
lrow = .Cells(Rows.Count, 2).End(xlUp).Row
Set i = ThisWorkbook.Sheets("Clienti").Range(Cells(1, 2), Cells(lrow, 2))
Set i = Clienti.Range(Cells(1, 2), Cells(lrow, 2))
Set i = Clienti.Range(Cells(1, 2), Cells(lrow, 2))

End With
Me.CMBCliente.ListFillRange = i.Address

End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
maybe the range was not set...

Code:
Private Sub CMBCliente_DropButt*******()


Dim i As Range
Dim Clienti As Worksheet
Dim lrow As Long


Set Clienti = Sheets("Clienti")


With Clienti
  .activate
  Range("A1").select 
  lrow = ActiveSheet.UsedRange.Rows.Count
  Set i = .Range(Cells(1, 2), Cells(lrow, 2))


End With
Me.CMBCliente.ListFillRange = i.Address
End Sub
 
Upvote 0
In this,

Code:
Set i = ThisWorkbook.Sheets("Clienti").Range(Cells(1, 2), Cells(lrow, 2))

The two Cells references are to the active worksheet.

This might work:

Code:
Private Sub CMBCliente_DropButt*******()
  Dim wks           As Worksheet

  Set wks = Worksheets("Clienti")
  Me.CMBCliente.ListFillRange = wks.Range("B1", wks.Cells(wks.Rows.Count, "B").End(xlUp))
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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