Macro commands

bigsistar12

New Member
Joined
Mar 10, 2011
Messages
18
I am pretty new to Visual Basic and Macros. I can create general easy macros but this one Im scratching my head at.

I am trying to create a spreadsheet that takes information from a form I create and it copies the values within the form cells over to a spreadsheet that only needs the current values.

This is what I am doing

Sheets("Pricing Calculator").Select
Range("A2:D2").Select
ActiveCell.FormulaR1C1 = "michelle"
Sheets("worksheet 2").Select
Range("A2").Select
ActiveCell.FormulaR1C1 = "michelle"

the problem is that when i run this macro from pricing calculator to worksheet 2 it always populates the name michelle. I obviously know this is wrong but how do i get the current value only to be copied from one cell in pricing calculator to be pasted in worksheet two active cell? If I copy the cell entirely it pastes over with cell properties (ex color and size), which I dont want. My calculator is going to be updated and changed constantly but the new information that is added there needs to be saved in a master spreadsheet (wksht 2) not repopulating the old information.

example:
Sheets("worksheet 2").Select
Rows("3:3").Select
Selection.Insert Shift:=xlDown
Sheets("Pricing Calculator").Select
Range("A2:D2").Select
ActiveCell.FormulaR1C1 = "michelle"
Sheets("worksheet 2 ").Select
Range("A2").Select
ActiveCell.FormulaR1C1 = "michelle"
Sheets("Pricing Calculator").Select
Range("H3").Select
ActiveCell.FormulaR1C1 = "464604646"
Sheets("worksheet 2 ").Select
Range("B2").Select

id appreciate any help i can get. :smile:
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Welcome to the boards. If no one answers you in a day or so, don't get discouraged just repost your question and try to think of ways to make it easier to understand what it is that you're asking.

This is what I just came up with:

Code:
Sub CopyFormula()
Dim s1 As Worksheet
Dim s2 As Worksheet
Set s1 = ActiveWorkbook.Sheets("Sheet1")
Set s2 = ActiveWorkbook.Sheets("Sheet2")
s2.Cells(3, 3).Formula = s1.Cells(2, 2).Formula
End Sub

I know this isn't exactly what you are asking but I don't quite understand what you want. If you want to copy just formulas this is probably a good starting point for you since it won't copy formats or anything else, just the formula.

Now if it's just the value you want to copy replace

Code:
s2.Cells(3, 3).Formula = s1.Cells(2, 2).Formula

with

Code:
s2.Cells(3, 3).Value = s1.Cells(2, 2).Value

Just for clarity - I have two sheets "Sheet1" and "Sheet2". In cell "B2" on "Sheet1" I have a formula. After I run this macro, the same formula appears on "Sheet2" in cell "C3".

Hope that helps.

Try to mess around with this and then ask questions to clear up any areas that aren't making sense.
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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