Special Cell question

Sri_VBANoob

New Member
Joined
Oct 2, 2013
Messages
3
hi all, i am a noob to VBA with a relatively low exposure to programming, i am trying to achieve the below objective but getting error message

Objective: select last non blank row and offset to next cell type a message in it
error message: Runtime error 1004 : method 'Range' of Object '_Global' Failed

CODE:

Sub lastRowAll()
myvar = ActiveSheet.UsedRange.SpecialCells(11).Column
myrow = ActiveSheet.UsedRange.SpecialCells(11).Row
Range(myvar, myrow).Offset(0, 1).Value = "Experiments with VBA"
Range(myvar, myrow).Offset(0, 1).Activate


End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try Cells instead of Range:

Code:
Sub lastRowAll()

    With Cells(1).SpecialCells(11)
        myvar = .Column
        myrow = .Row
    End With
    
    Cells(myrow, myvar).Offset(0, 1).Value = "Experiments with VBA"


End Sub

or simply:


Code:
Sub lastRowAll()


    Cells(1).SpecialCells(11).Offset(0, 1).Value = "Experiments with VBA"


End Sub
 
Upvote 0
What do you mean? They are in the code... ActiveSheet is fine too.

This works !!!!

Thanks a ton for helping out Wigi, this fixes my broken code(heart) :) , and James appreciate your help in reaching out

cheers
Sri_VBANoob
 
Last edited:
Upvote 0
You're welcome.
Please can you pay attention to the
Code:
 tags? Thanks in advance.
 
Upvote 0

Forum statistics

Threads
1,214,654
Messages
6,120,758
Members
448,991
Latest member
Hanakoro

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