Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Michael
 
Posts: n/a
Default copying formulas in vba

Hey guys.

I was wondering if someone could help me. I am writing a vba script that
takes in data, analyzes it, and then copies the results to a new file. I am
having a problem with two things.

1) I am using a template for the new file so there are a lot of formulas
(sums and std) already defined and ready to use. However, there are some
instances where there is a random amount of additional data I have to put in.
So, I have to apply the same formulas to this new data. How do I copy
formulas from one cell to another (allowing for a change in row) in vba?

Lets say cell(1,4) has the formula "=sum(A1:C1)
If I do: cells(4,4).formula = cells(1,4).formula
then cell(4,4) has the formula "=sum(A1:C1)"

How do I make it become "=sum(A4:C4)" using vba?

2) For these new cells, I also have to format some columns (currency, date,
etc) them and also put borders around them. How do I set these properties in
vba?

I greatly appreciate and assistance you could provide.

Thanks,

-Michael
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default copying formulas in vba

1)

Cells(1, 4).Copy
Cells(4, 4).PasteSpecial Paste:=xlPasteFormulas

2) There is a BorderARound property for a range that you could use. Check it
out in help.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Michael" wrote in message
...
Hey guys.

I was wondering if someone could help me. I am writing a vba script that
takes in data, analyzes it, and then copies the results to a new file. I

am
having a problem with two things.

1) I am using a template for the new file so there are a lot of formulas
(sums and std) already defined and ready to use. However, there are some
instances where there is a random amount of additional data I have to put

in.
So, I have to apply the same formulas to this new data. How do I copy
formulas from one cell to another (allowing for a change in row) in vba?

Lets say cell(1,4) has the formula "=sum(A1:C1)
If I do: cells(4,4).formula = cells(1,4).formula
then cell(4,4) has the formula "=sum(A1:C1)"

How do I make it become "=sum(A4:C4)" using vba?

2) For these new cells, I also have to format some columns (currency,

date,
etc) them and also put borders around them. How do I set these properties

in
vba?

I greatly appreciate and assistance you could provide.

Thanks,

-Michael



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
Excel Error when copying formulas Joe Gieder Excel Worksheet Functions 2 March 18th 05 05:01 PM
excel 2002 - copying formulas to another worksheet Greg Excel Discussion (Misc queries) 2 January 28th 05 10:23 PM
Excel 2002 - copying formulas across worksheets Greg Excel Discussion (Misc queries) 1 January 27th 05 10:45 PM
Copying options: contents, results, formulas, etc. Top Spin New Users to Excel 2 December 20th 04 04:54 PM
Excel & Copying Formulas JComer Excel Worksheet Functions 1 October 28th 04 07:17 PM


All times are GMT +1. The time now is 10:58 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"