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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
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
 

catrinawhite

New Member
Joined
Oct 2, 2006
Messages
6
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
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
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
 

Forum statistics

Threads
1,144,702
Messages
5,725,835
Members
422,645
Latest member
Victor9903

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