A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Updating cells



 
 
Thread Tools Display Modes
  #1  
Old May 29th, 2009, 04:49 PM posted to microsoft.public.excel.misc
Scafidel[_3_]
external usenet poster
 
Posts: 11
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  
Old May 29th, 2009, 05:03 PM posted to microsoft.public.excel.misc
Gary''s Student
external usenet poster
 
Posts: 7,584
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  
Old May 29th, 2009, 09:14 PM posted to microsoft.public.excel.misc
Scafidel[_3_]
external usenet poster
 
Posts: 11
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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:41 PM.


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