![]() |
|
![]() | ||
|
Subject:
Microsoft xl question
Category: Computers Asked by: mickr-ga List Price: $25.00 |
Posted:
19 Aug 2004 05:44 PDT
Expires: 20 Aug 2004 01:34 PDT Question ID: 389875 |
I have a spreadsheet with lots of numeric enteries along with some empty cells. I want to add a specified number to all the enteries. If the new valse is greater than or equal to zero I want the cell to be empty. Otherwise I want the new number to be specified. For example A B C D 1 name name1 name2 name3 2 mode1 -0.75 -2.25 4 3 mode2 -0.23 -1.45 4 mode3 -1.24 -3 and lets say the specified range was a2:d4 and the number was 1.0 so I would have A B C D 1 name name1 name2 name3 2 mode1 0.25 -1.25 5 3 mode2 0.77 -0.45 4 mode3 -0.24 -2 then blanking cells greater than 0 A B C D 1 name name1 name2 name3 2 mode1 -1.25 3 mode2 -0.45 3 mode3 -0.24 -2 I would like to specify the range of cells and also the number to be added. What is the best way of doing this? |
![]() | ||
|
There is no answer at this time. |
![]() | ||
|
Subject:
Re: Microsoft xl question
From: dreamboat-ga on 19 Aug 2004 22:43 PDT |
Open your file. Hit Alt+F11 to open the Visual Basic Editor (VBE) window. From the menu, choose Insert-Module. A code window should appear at the right-hand side of your screen. Paste the following code into that window: START CODE----------------- Option Explicit Sub Macro1() 'Presented By www.vbaexpress.com Dim Rng1 As Range Dim Prompt As String Dim Title As String Dim Value As Double Dim c As Range Prompt = "Select the range you want to work with." Title = "Range Input" Set Rng1 = Application.InputBox(Prompt, Title, Selection.Address, , , , , 8) Prompt = "Input the number that you want to add to each value." Title = "Number Input" Value = Val(InputBox(Prompt, Title)) For Each c In Rng1 If IsNumeric(c.Value) Then c.Value = c.Value + Value End If If c.Value > 0 And IsNumeric(c.Value) Then c.ClearContents End If Next End Sub END CODE ------------------ Hit the SAVE diskette on the toolbar to save the code into the file, and then close the VBE window. You can assign this macro to a keyboard shortcut or other object by going to the help file and looking for this topic: Assign a macro to run from a keyboard shortcut, a graphic object, or a toolbar button I hope this helps! Sorry if I took any money away from the researchers... My name is Dreamboat. |
Subject:
Re: Microsoft xl question
From: mickr-ga on 20 Aug 2004 01:34 PDT |
Hi Dreamboat, Thanks! It works perfectly. I know you are not a researcher but is there anyway to pay you as it is easily worth the $25 to me. Thank you very very much!!! Mick |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |