#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Updating cells

I have a workbook with merged cells with code that increases row height as
needed according to size of the string. I created a macro that essentially
goes to each such cell and hits <F2 <enter causing the cell to update and
readjust to the new string size. But since the macro uses Activecell.Formula,
inserting the formula, if I change the formula, I have to remember to change
it in the code, too.
Is there any way to accomplish updating the formula results without using
Activecell.Formula in VBA?
Thanks

--
Scafidel
Lafayette, Louisiana
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Updating cells

Why do you need to remember to change it in the code?
Why keep the formula in the code at all?

Just capture the formula from the sheet:

Dim S as String
S = Range("A1").Formula

and then later on:

Range("A1").Formula = S


The alternative is to use SendKeys to refresh all formula cells:

Sub refreshh()
Set r = ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormu las)
For Each rr In r
rr.Select
Application.SendKeys "{F2}"
Application.SendKeys "{ENTER}"
DoEvents
Next
End Sub

--
Gary''s Student - gsnu200855


"Scafidel" wrote:

I have a workbook with merged cells with code that increases row height as
needed according to size of the string. I created a macro that essentially
goes to each such cell and hits <F2 <enter causing the cell to update and
readjust to the new string size. But since the macro uses Activecell.Formula,
inserting the formula, if I change the formula, I have to remember to change
it in the code, too.
Is there any way to accomplish updating the formula results without using
Activecell.Formula in VBA?
Thanks

--
Scafidel
Lafayette, Louisiana

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Updating cells

Thanks, Sendkeys was the ticket!
--
Scafidel
Lafayette, Louisiana


"Gary''s Student" wrote:

Why do you need to remember to change it in the code?
Why keep the formula in the code at all?

Just capture the formula from the sheet:

Dim S as String
S = Range("A1").Formula

and then later on:

Range("A1").Formula = S


The alternative is to use SendKeys to refresh all formula cells:

Sub refreshh()
Set r = ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormu las)
For Each rr In r
rr.Select
Application.SendKeys "{F2}"
Application.SendKeys "{ENTER}"
DoEvents
Next
End Sub

--
Gary''s Student - gsnu200855


"Scafidel" wrote:

I have a workbook with merged cells with code that increases row height as
needed according to size of the string. I created a macro that essentially
goes to each such cell and hits <F2 <enter causing the cell to update and
readjust to the new string size. But since the macro uses Activecell.Formula,
inserting the formula, if I change the formula, I have to remember to change
it in the code, too.
Is there any way to accomplish updating the formula results without using
Activecell.Formula in VBA?
Thanks

--
Scafidel
Lafayette, Louisiana

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cells not updating TetrahedreX Excel Discussion (Misc queries) 3 March 5th 09 05:28 PM
Cells not updating RonJr Excel Worksheet Functions 4 January 28th 09 01:26 PM
Cells are not updating Graeme Excel Discussion (Misc queries) 4 June 27th 07 03:58 PM
Please Help! Cells not updating... Southwest Scott Excel Discussion (Misc queries) 4 April 27th 07 03:50 PM
Cells not updating Shaggyjh Excel Worksheet Functions 4 April 22nd 05 02:54 PM


All times are GMT +1. The time now is 06:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"