Solved

Remove all formulas in column of active cell.

Posted on 2013-12-20
5
409 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

733 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