Solved

Remove all formulas in column of active cell.

Posted on 2013-12-20
5
408 Views
Last Modified: 2013-12-22
This code changes the formulas to ValuesAndNumberFormats on Col A.
How would I convert this to work on whatever column the active cell is in?  To capture however many cell in that column has a formula in it...  I do not believe there will be any spaces.

Plan is to use this in multiple places in a project.  Please advise and thanks. -R-

Sub CopySpecialPasteValuesAndNumberFormats()
'
' CopySpecialPasteValuesAndNumberFormats Macro
' Need to change this to whatever the column is of the active cell
' For reuse throughout the workbook
'
    Columns("A:A").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False
    Application.CutCopyMode = False
End Sub

Open in new window

0
Comment
Question by:RWayneH
5 Comments
 
LVL 33

Expert Comment

by:Rob Henson
ID: 39731658
Line 7, Rather than

Columns("A:A).Select

Use

C = Activecell.Column
Cells(1,C).Select
ActiveCell.EntireColumn.Select


The first two lines ensure you are in row 1 when copy/pasting.
Thanks
Rob H
0
 
LVL 19

Expert Comment

by:regmigrant
ID: 39731662
change columns("A:A").select to

ActiveCell.EntireColumn.Select

if you just want a single column

Change to
Selection.EntireColumn.Select


if you want all the columns in a multiple select.

NB: watch out for merged cells!

Reg
0
 
LVL 33

Assisted Solution

by:Rob Henson
Rob Henson earned 250 total points
ID: 39731677
Or using similar method to earlier suggestion, assuming no blank cells as per question:

C = Activecell.Column
Cells(1,C).Select
Do Until Cell.Value = ""
Cell.Value = Cell.Value
ActiveCell.Offset(1,0)
Loop

This will overwrite formulas with values and/but will leave formatting alone.

Thanks
Rob H
0
 
LVL 81

Accepted Solution

by:
byundt earned 250 total points
ID: 39732109
You could also remove the formulas with this one-liner:
Sub CopySpecialPasteValuesAndNumberFormats()
ActiveCell.EntireColumn.Formula = ActiveCell.EntireColumn.Value
End Sub

Open in new window

0
 

Author Closing Comment

by:RWayneH
ID: 39735106
Thanks -R-
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
Outlook Free & Paid Tools
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question