VBA code to place formulas

Lorlai

Board Regular
Joined
May 26, 2011
Messages
85
I have some code that works great for when my data is on the same worksheet. I want to leverage this so that I can keep the data on two worksheets and have a new worksheet for the formulas. I am having some difficulty, however. Is there a way to take this:

Code:
'code courtesy of [URL="http://www.mrexcel.com/forum/member.php?u=26558"]Norie[/URL]
    Dim wsnew As Worksheet
    Set wsnew = Worksheets.Add
    
    wsnew.Range("A1:BC200").Offset(, wsnew.Cells(1, Columns.Count).End(xlToLeft).Column + 2).Formula = "=A1=A203"
And have it compare the columns for two different sheets? So that it would become ='Sheet1'A1='Sheet2'A1?

Thank you for your help!
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Rich (BB code):
'code courtesy of Wigi
Sub ComparingSheets()
    Const sCell As String = "A1"
    Sheets.Add.Range(sCell).Formula = "=Sheet1!" & sCell & "=Sheet2!" & sCell
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,762
Members
452,940
Latest member
rootytrip

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