Solved

Remove all formulas in column of active cell.

Posted on 2013-12-20
5
404 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 31

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 31

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 80

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now