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 December 31st, 2004, 10:20 AM
Authorized User
 
Join Date: Dec 2004
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default Taking headers out of spreadsheet

Hi
I'm fairly new to VBA and excel so this might be an easy one. Two problems; firstly I've a column of figures in an excel spread sheet. Some of the figures are negative but are in the wrong format ie they are written with the negative sign to the right of the figure (eg 34-)
instead of to the left (-34). I thus need to move the sign from the right to the left.
Also I have headers repeated throughout the spreadsheet that I want to delete. Any tips?

Cheers
Tony
__________________
Cheers
Tony
 
Old December 31st, 2004, 11:07 AM
Authorized User
 
Join Date: Oct 2004
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to shattered Send a message via Yahoo to shattered
Default

well, one solution to the first problem is as follows (and yes I know its not the neatest code but I'm only on a coffee break)..

Public Sub SortNegatives()
Dim iData As Integer: Dim iRow As Integer: Dim iCol As Integer
iRow = 2 ' Where iRow is the first row where the values are stored
iCol = 3 ' Where iCol is the column in which the values are stored
Do Until Cells(iRow, iCol).Value = ""
    If Right(Cells(iRow, iCol).Value, 1) = "-" Then
        iData = "-" & Mid(Cells(iRow, iCol).Value, 1, Len(Cells(iRow, iCol).Value) - 1)
        Cells(iRow, iCol).Value = iData
    End If
    iRow = iRow + 1
Loop
End Sub

Just call that procedure and specify which column and row to start in. If those deatils change you can always add them in via an input box just to make life easier.

as for the second problem...

Sub ClearHeaders()
With ActiveSheet.PageSetup
    .LeftHeader = ""
    .CenterHeader = ""
    .RightHeader = ""
    .LeftFooter = ""
    .CenterFooter = ""
    .RightFooter = ""
End With
End Sub

That can be repeated for each sheet on a for each loop if need be.

 
Old January 4th, 2005, 05:35 AM
Authorized User
 
Join Date: Dec 2004
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Thanks for that. The code for fixing the negatives does indeed work for a few records but I have just over 20000 and an overflow occurs. Is there a way around this?



Cheers
Tony





Similar Threads
Thread Thread Starter Forum Replies Last Post
Script taking too long mmltonge Classic ASP Professional 3 April 16th, 2007 06:56 PM
taking particular data .. anukagni Access 2 August 4th, 2006 12:05 AM
Taking values from textbox derekl ASP.NET 1.0 and 1.1 Professional 3 February 20th, 2006 08:30 AM
Taking action for several attributes raoulvb XSLT 1 December 1st, 2004 07:57 AM
Taking information from a cookie snowy0 HTML Code Clinic 1 May 18th, 2004 07:46 PM





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