VBA Relative Cell Reference

catrinawhite

New Member
Joined
Oct 2, 2006
Messages
6
Hi all! I am writing a program which does a search of spreadsheets and upon finding the desired information it pastes it into a new spreadsheet. My problem is I cannot get it to move to the next cell to the right after pasting. I know it is something really simple but I cannot get it to work. Any help would be greatly appreciated. Thank you!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Welcome to the Board!

You can use End & Offset:

Code:
Range("IV1").End(xltoLeft).Offset(,1)

If you post your code we can adjust it accordingly.

HTH,

Smitty
 
Upvote 0
Thanks Sitty! I am getting a syntax error on the code you posted. Here is a tiny section of what I am trying to do. You can see where I inserted your suggestions.

Cells.Find(What:="Size:", After:=ActiveCell, LookIn:=xlFormulas, LookAt
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Activate
Selection.Copy
Windows("Pricing.xls").Activate
ActiveSheet.Paste
Range("IV1").End(xltoLeft).Offset(,1)
ActiveWindow.ActivateNext
 
Upvote 0
Does this do it:

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> foo()
    Cells.Find(What:="Size", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        <SPAN style="color:#00007F">False</SPAN>, SearchFormat:=False).Copy
        
    Windows("Pricing.xls").Activate
    Sheets("Sheet1").Range("IV1").End(xlToLeft).Offset(, 1).Select
    
    ActiveSheet.Paste
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>

Smitty
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,253
Members
448,556
Latest member
peterhess2002

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