Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Repetitive task macro

Would anyone be able to help me write a macro which takes the followin
table of plain numbers and inserts a formula into the last cell whic
multiplies the quantity by the unit and copies it all the way down.

And then replace the plain total value at the bottom into a sum cel
totalling all the subtotals above.

The amount of data varies from one text import to the next as well. I
this example it is 3 lines, but it could in practice be any number o
lines of data and

Qty Code Description Unit SubTotal
2, CD1,Desc001,10,20
3,CD2,DESC003,30,90
4,CD3,DESC004,40,160
,,,Grand Total,270

Thanks in hope.

T

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Repetitive task macro

Hi
try:
Sub insert_formula()
Dim lastrow As Long
Dim sformula
Application.ScreenUpdating = False
sformula = "=R[0]C[-4]*R[0]C[-1]"
With ActiveSheet
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("E2:E" & lastrow).FormulaR1C1 = sformula
.Range("E" & lastrow + 1).FormulaR1C1 = "=sum(R2C
[0]:R" & lastrow & "C[0])"
End With
Application.ScreenUpdating = True
End Sub

-----Original Message-----
Would anyone be able to help me write a macro which takes

the following
table of plain numbers and inserts a formula into the

last cell which
multiplies the quantity by the unit and copies it all the

way down.

And then replace the plain total value at the bottom into

a sum cell
totalling all the subtotals above.

The amount of data varies from one text import to the

next as well. In
this example it is 3 lines, but it could in practice be

any number of
lines of data and

Qty Code Description Unit SubTotal
2, CD1,Desc001,10,20
3,CD2,DESC003,30,90
4,CD3,DESC004,40,160
,,,Grand Total,270

Thanks in hope.

TW


---
Message posted from http://www.ExcelForum.com/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Repetitive task macro

Thanks Frank for your help as always.

However the editor doesn't like the following line which is coming u
as highlighted in red ?

Any ideas on whats happening here ?

Thank

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Repetitive task macro

Probably a word wrap problem. Try this:

Sub insert_formula()
Dim lastrow As Long
Dim sformula
Application.ScreenUpdating = False
sformula = "=R[0]C[-4]*R[0]C[-1]"
With ActiveSheet
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("E2:E" & lastrow).FormulaR1C1 = sformula
.Range("E" & lastrow + 1).FormulaR1C1 = _
"=sum(R2C[0]:R" & lastrow & "C[0])"
End With
Application.ScreenUpdating = True
End Sub

--
Regards,
Tom Ogilvy


"twaccess " wrote in message
...
Thanks Frank for your help as always.

However the editor doesn't like the following line which is coming up
as highlighted in red ?

Any ideas on whats happening here ?

Thanks


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Repetitive task macro

Sorry this is the text that is coming up in Red

[0]:R" & lastrow & "C[0])"

Thank

--
Message posted from http://www.ExcelForum.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Repetitive task macro

Answered.

--
Regards,
Tom Ogilvy

"twaccess " wrote in message
...
Sorry this is the text that is coming up in Red

[0]:R" & lastrow & "C[0])"

Thanks


---
Message posted from http://www.ExcelForum.com/



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Repetitive task macro

Hi Tom
thanks for stepping in :-)

Regards
Frank

-----Original Message-----
Answered.

--
Regards,
Tom Ogilvy

"twaccess "

wrote in message
...
Sorry this is the text that is coming up in Red

[0]:R" & lastrow & "C[0])"

Thanks


---
Message posted from http://www.ExcelForum.com/



.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Repetitive task macro

Thanks guys

It was a text wrapping issue. I should have checked this first !

Regards


Terr

--
Message posted from http://www.ExcelForum.com

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
Event macro for a task TUNGANA KURMA RAJU Excel Discussion (Misc queries) 8 January 6th 06 10:43 AM
macro to automise the task TUNGANA KURMA RAJU Excel Discussion (Misc queries) 3 December 7th 05 07:42 PM
Macro -- repetitive tasks OTS Excel Discussion (Misc queries) 1 October 7th 05 04:23 PM
Using macro to run repetitive tasks OTS Excel Discussion (Misc queries) 1 October 7th 05 01:37 PM
Task Schedule for Macro mike0021[_3_] Excel Programming 3 May 25th 04 08:14 PM


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

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

About Us

"It's about Microsoft Excel"