?
Solved

Remove all formulas in column of active cell.

Posted on 2013-12-20
5
Medium Priority
?
412 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 1000 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 1000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

777 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