Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 24th, 2007, 11:48 PM
Registered User
 
Join Date: Aug 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Formula on Active Cell

Dear Expert

I am using an excel sheet with some rows and colunms

all are having numeric data

i want to divide all the data by 2 without using new sheet or reference .

I want to use formula on active cells or selection.

what is the solution.

should i use macro.

please help

thanks

manoj
 
Old August 26th, 2007, 01:46 AM
Registered User
 
Join Date: Aug 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

easiest is to have a macro something like these code statements
Code:
sub test()
dim c as range
for each c in activesheet.usedrange
c=c/2
next
end sub
 
Old August 26th, 2007, 02:25 AM
Registered User
 
Join Date: Aug 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear Sir

after putting this code in to macro, it gives an error

Type mismatch

can you show me with more details on it.

should i select the sheet first, or
before running the macro data should be selected

please help me

yours
manoj
 
Old August 26th, 2007, 08:56 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

You have some data in your sheet which is not numeric.
That´s why you get Type Mismatch error.
To avoid error change the code like this.

Sub test()
Dim c As Range
For Each c In ActiveSheet.UsedRange
If IsNumeric(c) And c <> "" Then
    c = c / 2
End If
Next

End Sub


-vemaju





Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel putting result of a formula in another Cell hakimk Excel VBA 8 July 29th, 2016 12:35 AM
insert text to active cell by shared add-in Medes Excel VBA 0 May 5th, 2006 01:53 AM
What would the formula "=+D4" do in a cell? BrianWren Excel VBA 2 February 2nd, 2006 03:36 AM
Inserting formula into active cell alisonchase Excel VBA 3 March 3rd, 2005 10:06 AM
Cell returns its own formula after a macro! timoma Excel VBA 2 December 19th, 2004 03:48 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.