Worksheet Referencing Problem?

Willow123

New Member
Joined
Dec 29, 2018
Messages
17
Hi All,

So I made a little program and now am in the process of making it into an Add-In. After it was loaded as an Add-In it did not work quite right. It was how the worksheets were referenced. I fixed all the bugs but this one. So what should be happening, and works fine when I'm not using the code in an Add-In, Is this bit of code should be comparing one string to another. When used as an Add-In it does not work correctly and I believe it is because I don't properly state to do it on Worksheet 2 of the active Workbook. I've tried a couple different things but to no avail. Any thoughts would be greatly appreciated.

Code:
[FONT=Verdana]Sub TagType_Click()

[/FONT]
[FONT=Verdana]Dim wb1 As Workbook, shxx As Worksheet[/FONT]
[FONT=Verdana]Set wb1 = ActiveWorkbook

Set shxx = wb1.Sheets(2)[/FONT]
[FONT=Verdana]
   Dim Cl As Range[/FONT]
[FONT=Verdana]
shxx.Activate 'This will activate the sheet but does not solve the problem
ActiveSheet.Range("I1").Select

With ActiveSheet 'This does not appear to do anything
   With CreateObject("scripting.dictionary")
      For Each Cl In Range("I1", Range("I1").End(xlDown)) 'Tried changing how the cells will be referenced
         .Item(Cl.Value) = Cl.Offset(, 1).Value                     'Did not work out
      Next Cl
      For Each Cl In Range("C1", Range("C1").End(xlDown))
         Cl.Offset(, 1).Value = .Item(Cl.Value)
      Next Cl
   End With
End With[/FONT]
[FONT=Verdana]
End Sub[/FONT]
 

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.
Try
Code:
Sub TagType_Click()


Dim wb1 As Workbook, shxx As Worksheet
Set wb1 = ActiveWorkbook

Set shxx = wb1.Sheets(2)

   Dim Cl As Range


   With CreateObject("scripting.dictionary")
      For Each Cl In shxx.Range("I1", shxx.Range("I1").End(xlDown)) 'Tried changing how the cells will be referenced
         .Item(Cl.Value) = Cl.Offset(, 1).Value                     'Did not work out
      Next Cl
      For Each Cl In shxx.Range("C1", shxx.Range("C1").End(xlDown))
         Cl.Offset(, 1).Value = .Item(Cl.Value)
      Next Cl
   End With

End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,172
Members
449,071
Latest member
cdnMech

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