Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tb tb is offline
external usenet poster
 
Posts: 84
Default Need Macro...

I am using Microsoft Office 2007, 32-bit. I know absolutely nothing
about macros, so, I am hoping that somebody in this group can help me
out.

I have an Excel workbook with several worksheets in it. Each worksheet
has list prices for some of our products, and my task is to apply an X
% price increase to each cell that has a price in it.

The problem is that list prices are in the form of complex tables, thus
it is hard and time consuming to create a formula in some blank column
of each worksheet that calculates the new prices and then copy/paste
the results over to appropriate tables' cells.

What I would like to do is enter the % increase into a cell of the
first worksheet (say cell A1 of Sheet1) and then launch a macro that
will find all the cells that are formatted as currency (in each
worksheet) and apply the % increase.

The only details to keep in mind when writing the macro a
* The X % percentage increase is across the board (i.e. all prices in
all worksheets will get the same % increase);
* Rounding should be to two decimals;
* If a cell formatted as currency is blank (empty), then that cell
needs to stay blank.

Can anyone please help me?
--
tb
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Need Macro...

Hi,

Am Mon, 8 Dec 2014 23:43:15 +0000 (UTC) schrieb tb:

What I would like to do is enter the % increase into a cell of the
first worksheet (say cell A1 of Sheet1) and then launch a macro that
will find all the cells that are formatted as currency (in each
worksheet) and apply the % increase.


try:

Sub Test()
Dim i As Long
Dim rngC As Range

For i = 1 To Sheets.Count
For Each rngC In Sheets(i).UsedRange
If Len(rngC) 0 And rngC.Style = "Currency" Then
'rngc will increased by 5%
rngC = rngC * 1.05
End If
Next
Next
End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #3   Report Post  
Posted to microsoft.public.excel.programming
tb tb is offline
external usenet poster
 
Posts: 84
Default Need Macro...

On 12/9/2014 at 6:34:56 AM Claus Busch wrote:


try:

Sub Test()
Dim i As Long
Dim rngC As Range

For i = 1 To Sheets.Count
For Each rngC In Sheets(i).UsedRange
If Len(rngC) 0 And rngC.Style = "Currency" Then
'rngc will increased by 5%
rngC = rngC * 1.05
End If
Next
Next
End Sub


Regards
Claus B.


I am getting "Run-time error 13" and "Type mismatch" errors. I'm not
a macro expert so I don't know how to debug this.

Also, where in your macro does the user enter the desired % increase
and where does it round to two decimals?

--
tb
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Need Macro...

Hi,

Am Tue, 9 Dec 2014 18:36:06 +0000 (UTC) schrieb tb:

'rngc will be increased by 5%
rngC = rngC * 1.05


I am getting "Run-time error 13" and "Type mismatch" errors. I'm not
a macro expert so I don't know how to debug this.

Also, where in your macro does the user enter the desired % increase
and where does it round to two decimals?


look to the lines above.
You don't have to round because you have Currency as format.
I don't know why you get these errors because I don't know your data. In
my tests the code worked fine.


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #5   Report Post  
Posted to microsoft.public.excel.programming
tb tb is offline
external usenet poster
 
Posts: 84
Default Need Macro...

On 12/9/2014 at 12:44:03 PM Claus Busch wrote:


look to the lines above.
You don't have to round because you have Currency as format.
I don't know why you get these errors because I don't know your data.
In my tests the code worked fine.


Regards
Claus B.


Is there a place where I could post the file or do you have an email
address where I could send it?

Thanks and regards.
--
tb


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Need Macro...

Hi,

Am Tue, 9 Dec 2014 21:19:22 +0000 (UTC) schrieb tb:

Is there a place where I could post the file or do you have an email
address where I could send it?


you could upload your file to a filehoster like DropBox or into a cloud
line OneDrive.
Or send it to me claus_busch(at)t-online.de


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #7   Report Post  
Posted to microsoft.public.excel.programming
tb tb is offline
external usenet poster
 
Posts: 84
Default Need Macro...

On 12/10/2014 at 12:32:40 AM Claus Busch wrote:

Hi,

Am Tue, 9 Dec 2014 21:19:22 +0000 (UTC) schrieb tb:

Is there a place where I could post the file or do you have an email
address where I could send it?


you could upload your file to a filehoster like DropBox or into a
cloud line OneDrive.
Or send it to me claus_busch(at)t-online.de


Regards
Claus B.


Thanks, Claus. I just sent the Excel file to your email address.
Hopefully you can help me out.
Regards.
--
tb
  #8   Report Post  
Posted to microsoft.public.excel.programming
tb tb is offline
external usenet poster
 
Posts: 84
Default Need Macro...

Hi Claus. Messages sent to your email account bounce back, so I am
posting here.

I ran the macro that you created both at work and at home, with Excel
2007 and 2010. But I still get nothing -- no prices are changed!

Just want to make sure one more time that I am doing things right since
I am no macro expert.

1) I made sure that "Enable all macros" is selected in the security
level.
2) I entered the % increase in cell O2 of the ATEX tab.
3) I pressed ALT+F8 and selected "Test" as the macro name.
4) I pressed the Run button.
5) A rotating blue circle appears for a few seconds then it is gone.
6) Waited for prices to be changed but nothing happened after waiting a
long time.

Do you see anything wrong with what I am doing?

Best regards.
--
tb
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Need Macro...

Hi Tiziano,

Am Fri, 12 Dec 2014 15:21:35 +0000 (UTC) schrieb tb:

1) I made sure that "Enable all macros" is selected in the security
level.
2) I entered the % increase in cell O2 of the ATEX tab.
3) I pressed ALT+F8 and selected "Test" as the macro name.
4) I pressed the Run button.
5) A rotating blue circle appears for a few seconds then it is gone.
6) Waited for prices to be changed but nothing happened after waiting a
long time.


did you use the correct address? Yesterday you mailed me and I answered
you.
I don't know why the macro don't change the prices. Everytime I tested
the macro here it does exactly what you expect.


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor [email protected] Excel Programming 2 March 30th 07 07:48 PM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


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