Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default use macro to copy formula with value and not formula without value

let say i have formula as below
A1 - 5 (=b1*c1)
A2 - 5 (=b2*c2)
A3 - 5 (=b3*b3)
A4 - 0 (=b4*b4) (can be zero or blank)

i wanted my mcro to copy from A1-A4 but only paste A1-A3, b'coz A4 is not
value to calculate.

thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default use macro to copy formula with value and not formula without value

Try

Sub stantial()
Dim myrange As Range, NonZero As Range
Set myrange = Range("a1", Cells(Rows.Count, "a").End(xlUp))
Set NonZero = myrange(myrange.Rows.Count, myrange.Columns.Count)

Do Until NonZero 0
Set NonZero = myrange.Find(What:="*", After:=NonZero,
LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
Loop
Range("A1:" & NonZero.Address).Copy
End Sub

Mike

"ramzi" wrote:

let say i have formula as below
A1 - 5 (=b1*c1)
A2 - 5 (=b2*c2)
A3 - 5 (=b3*b3)
A4 - 0 (=b4*b4) (can be zero or blank)

i wanted my mcro to copy from A1-A4 but only paste A1-A3, b'coz A4 is not
value to calculate.

thanks in advance

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default use macro to copy formula with value and not formula without v

correction

Set NonZero = myrange(myrange.Rows.Count)


Mike

"Mike H" wrote:

Try

Sub stantial()
Dim myrange As Range, NonZero As Range
Set myrange = Range("a1", Cells(Rows.Count, "a").End(xlUp))
Set NonZero = myrange(myrange.Rows.Count, myrange.Columns.Count)

Do Until NonZero 0
Set NonZero = myrange.Find(What:="*", After:=NonZero,
LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
Loop
Range("A1:" & NonZero.Address).Copy
End Sub

Mike

"ramzi" wrote:

let say i have formula as below
A1 - 5 (=b1*c1)
A2 - 5 (=b2*c2)
A3 - 5 (=b3*b3)
A4 - 0 (=b4*b4) (can be zero or blank)

i wanted my mcro to copy from A1-A4 but only paste A1-A3, b'coz A4 is not
value to calculate.

thanks in advance

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default use macro to copy formula with value and not formula without v

hi Mike,
Thanks a lot, it works with one coloum. and my data actually in 7coloum and
different range of location as below (the example given earlier is A1:A4)

D8:J14 and O8:O14.

If my data is 0 at row 13 and 14 the macro will copy only D8:D12 and O8:O12.
I try to modify ur macro ealier but fails
I need your help again on this...:)
thanks

..

"Mike H" wrote:

correction

Set NonZero = myrange(myrange.Rows.Count)


Mike

"Mike H" wrote:

Try

Sub stantial()
Dim myrange As Range, NonZero As Range
Set myrange = Range("a1", Cells(Rows.Count, "a").End(xlUp))
Set NonZero = myrange(myrange.Rows.Count, myrange.Columns.Count)

Do Until NonZero 0
Set NonZero = myrange.Find(What:="*", After:=NonZero,
LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
Loop
Range("A1:" & NonZero.Address).Copy
End Sub

Mike

"ramzi" wrote:

let say i have formula as below
A1 - 5 (=b1*c1)
A2 - 5 (=b2*c2)
A3 - 5 (=b3*b3)
A4 - 0 (=b4*b4) (can be zero or blank)

i wanted my mcro to copy from A1-A4 but only paste A1-A3, b'coz A4 is not
value to calculate.

thanks in advance

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
Copy a Formula in a Macro KennyD Excel Discussion (Misc queries) 3 March 7th 10 01:04 AM
Copy down formula macro Eva Excel Worksheet Functions 3 December 9th 09 10:33 PM
Copy a formula down in a macro Sal Excel Discussion (Misc queries) 3 June 5th 06 02:52 AM
Copy Formula with a Macro J Excel Programming 4 August 24th 05 09:40 PM
Copy Formula Macro ME Pike Excel Programming 2 September 17th 03 09:42 PM


All times are GMT +1. The time now is 10:08 PM.

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"