Speficy cell in VBA using column letter and a row number

tightwad

Well-known Member
Joined
Feb 22, 2006
Messages
609
How do I specify a cell in VBA using a column letter, and a row # stored as a value?


CR is my "current row" that I am working with. It has been declared as a value

Set box = .document.all.Item(ThisWorkbook.Sheets("tbas").Range("A & CR").Offset(1, 1).Value)

This didn't work, but I don't know how to do it....it has to be simple.
 

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

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,303
Office Version
  1. 365
Platform
  1. Windows
Just move CR outside the quotes.
Code:
Set box = .document.all.Item(ThisWorkbook.Sheets("tbas").Range("A" & CR).Offset(1, 1).Value)
 

tightwad

Well-known Member
Joined
Feb 22, 2006
Messages
609

ADVERTISEMENT

I get an error 91

Object variable or with block variable not set

Any ideas?
 

Darren Bartrup

Well-known Member
Joined
Mar 13, 2006
Messages
1,296
Office Version
  1. 365
Platform
  1. Windows
Are all If and With statements closed?
i.e. End If & End With.
 

tightwad

Well-known Member
Joined
Feb 22, 2006
Messages
609

ADVERTISEMENT

Nevermind...seems to be a problem i brought in from elsewhere. Thanks!
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,303
Office Version
  1. 365
Platform
  1. Windows
What value is being returned by this?
Code:
ThisWorkbook.Sheets("tbas").Range("A" & CR).Offset(1, 1).Value
Does an item with that name exist on the document?
 

tightwad

Well-known Member
Joined
Feb 22, 2006
Messages
609
What value is being returned by this?
Code:
ThisWorkbook.Sheets("tbas").Range("A" & CR).Offset(1, 1).Value
Does an item with that name exist on the document?

The cell part was working, the problem was this Macro is designed to work with a form, but I was skipping the form part to test the cell address. I verified this by using my old process and getting the same error. Then I ran it throught he whole macro and it worked.

Didn't fix my problem with slowness, but it worked.
 

Forum statistics

Threads
1,141,203
Messages
5,704,934
Members
421,372
Latest member
Jamie11

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
Top