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 » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Formula in a coloum



 
 
Thread Tools Display Modes
  #1  
Old March 7th, 2010, 05:43 PM posted to microsoft.public.excel.newusers
franco monte
external usenet poster
 
Posts: 10
Default Formula in a coloum

I have this code

UltimaRiga = Range("A65356").End(xlUp).Row
For i = 3 To UltimaRiga
Range("G" & i).Value = (Range("D" & i).Value - Range("I" &
i).Value)
Range("G" & i).NumberFormat = "0_ ;[Red]-0 "
Next i

but I think is better (faster) without loop, is it possible?
Thanks in advance!
  #2  
Old March 7th, 2010, 06:45 PM posted to microsoft.public.excel.newusers
Dave Peterson
external usenet poster
 
Posts: 19,791
Default Formula in a coloum

You could fill the range with a formula, then convert those formulas to values:

Dim UltimaRiga as long
Dim myRng as range
With worksheets("Sheet1")
unltimariga = .cells(.rows.count,"A").end(xlup).row
set myrng = .range("G3:G" & ultimariga)
with myrng
.numberformat = "0_ ;[Red]-0 "
.formula = "=D3-I3"
.value = .value
end with
end with


franco monte wrote:

I have this code

UltimaRiga = Range("A65356").End(xlUp).Row
For i = 3 To UltimaRiga
Range("G" & i).Value = (Range("D" & i).Value - Range("I" &
i).Value)
Range("G" & i).NumberFormat = "0_ ;[Red]-0 "
Next i

but I think is better (faster) without loop, is it possible?
Thanks in advance!


--

Dave Peterson
  #3  
Old March 7th, 2010, 07:46 PM posted to microsoft.public.excel.newusers
franco monte
external usenet poster
 
Posts: 10
Default Formula in a coloum

Dave, can Yuo tell me what riferiments I nedd?
on the line Set myRng = .Range("G3:G" & UltimaRiga)
I have the error: Errore di run-time '1004'.
Errore definito dall'applicazione o dall'oggetto.
Thanks in advance
  #4  
Old March 7th, 2010, 07:49 PM posted to microsoft.public.excel.newusers
franco monte
external usenet poster
 
Posts: 10
Default Formula in a coloum

Dave, can You tell me what riferiments I need?
On the line Set myRng = .Range("G3:G" & UltimaRiga) I have the error:
Errore di run-time '1004'.
Errore definito dall'applicazione o dall'oggetto.
Thanks in advance!
  #5  
Old March 7th, 2010, 08:08 PM posted to microsoft.public.excel.newusers
franco monte
external usenet poster
 
Posts: 10
Default Formula in a coloum

Dave, it seems work correct, is it right for you?

With Range("G3:G" & UltimaRiga)
.NumberFormat = "0_ ;[Red]-0 "
.Formula = "=D3-I3"
.Value = .Value
End With

  #6  
Old March 7th, 2010, 08:12 PM posted to microsoft.public.excel.newusers
Dave Peterson
external usenet poster
 
Posts: 19,791
Default Formula in a coloum

Try fixing my typo.

I spelled ultimariga incorrectly on one of those lines.

franco monte wrote:

Dave, can You tell me what riferiments I need?
On the line Set myRng = .Range("G3:G" & UltimaRiga) I have the error:
Errore di run-time '1004'.
Errore definito dall'applicazione o dall'oggetto.
Thanks in advance!


--

Dave Peterson
  #7  
Old March 7th, 2010, 08:16 PM posted to microsoft.public.excel.newusers
Dave Peterson
external usenet poster
 
Posts: 19,791
Default Formula in a coloum

After the typo correction, it worked fine.

If you want to double check the formulas first, just comment that
".value = .value" line.



franco monte wrote:

Dave, it seems work correct, is it right for you?

With Range("G3:G" & UltimaRiga)
.NumberFormat = "0_ ;[Red]-0 "
.Formula = "=D3-I3"
.Value = .Value
End With


--

Dave Peterson
  #8  
Old March 7th, 2010, 08:24 PM posted to microsoft.public.excel.newusers
franco monte
external usenet poster
 
Posts: 10
Default Formula in a coloum

Dave, you are right!
I correct it and now it's ok!
Thank again!

  #9  
Old March 7th, 2010, 08:25 PM posted to microsoft.public.excel.newusers
franco monte
external usenet poster
 
Posts: 10
Default Formula in a coloum

Dave, you are right!
I correct it and now it's ok!
Thank again!

 




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 07:55 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.