Search: | |||||

| ||||

Home » Forum » MS Office | RSS Feeds |

When a user inputs a new row using my userform, I want to make it such that

the old values from the previous row are copied into the new row (basically

a copy/paste function). However, if the user has entered a formula such as

"=text(B115,"ddd")", I would like it to act EXACTLY like they did a select

and drag down operation, and therefore update the cell to be

"=text(B116,"ddd"). I have used the "record macro" function to find out

what Excel would do... and updated the references to be variable based

(instead of static).

Here's the rub.

If I run the resulting code from a module (while only calling it with

variables declared and set someplace else in the module) it works great.

However, if I call it from my userform, it will evaluate the formula and

place the result in the correct place, but will not paste the formula. I've

even transferred the .Formula property of the cell being copied into a

String (used a MSGBOX to verify that it was copied) and tried to transfer

that String into the .Formula property of the new

cell... no go. (It evaluated the formula, put the result in the box)

Here's the code I'm using with the .Formula property

If MakingNew = True and LineNo > 5 Then

cells(LineNo, i).Formula = cells(Lineno-1,i).Formula

end if

Anyone have any ideas?

Didn't find what you were looking for?
Find more on Getting a formula to copy from inside VBA
Or get search suggestion and latest updates.

Related Topics:

- Copy down formula with vba
- VBA Formula prob
- Formula using range name in VBA code
- VBA or array formula?
- VBA code to add values in two cells which have formulas
- formula help but not vba please
- cells containing formula that refer to user-defined VBA function
- VBA Code for pasting a set of formulas down a data range
- VBA variable range in a formula
- Stuck on copying formula from 1 sheet to another
- Copy Value produced by formula in cell C3 to cell D3
- Stuck on copying formula from 1 sheet
- copy down formulas in excel
- Excel VBA - need to copy paste conditional statement
- Copy and Paste using VBA
- Newbie VBA Macro question- Conditional Copy & Paste based on time
- New to VBA and need help with copy and paste
- VBA conditional formatting - copy & paste
- VBA conditional formatting - copy & paste
- Getting Excel DSO Properties in VBA Code
- Getting VBA to wait
- Placing VBA Code "Live" Into Another WkBook Via VBA
- writing vba code to generate vba code
- Cannot use the VBA add table command of MS word in MS Excel VBA
- Convert code from excel 2000 vba to excel 2003 vba