felds name in Excel

Posted on 2014-02-13
Last Modified: 2014-02-19
I have created a invoice with Excel. It allows users to input information on the it.

How easy to write a macro such that clear it will clear all the input fields on the excel invoice.

Some of the cells may not fix in a particular position. Can I make use of the range to mark the cell and then remove its content ? How can I make it work ?

Question by:AXISHK
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

Expert Comment

ID: 39858210
Hi it is very easy to make a macro for this.

The easiest way is to record a macro, and then do exactly what you want.

The code is slower than writing a VBA doing the same thing. But if you upload the file, it will only take a couple of minutes to write the VBA.

best regards


Assisted Solution

Jorgen earned 250 total points
ID: 39858218
Hi again

I just pasted the code to clear Content of cell B4. That hopefully can show you the way forward. otherwise send the file, and I will try to write the full code.

Public Sub Clear_Content()
' Procedure : Clear_Content
' Author    : Jørgen Wulff Rasmussen, Phone +45 2373 2009
' Date      : 14/02/2014
' Purpose   :This procedure is generated to show how to clear the content of a cell
' Modified
' Date          Developer             Action
' 14/02/2014    Jørgen Rasmussen      Created
End Sub

Open in new window

Best regards


Author Comment

ID: 39858236
Some content may not be fixed at special row. How can we handle it ?

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.


Expert Comment

ID: 39858269
That is not a problem either. In Principal in the same way.

But try to send the file, and I will have a look.

I need you to be more specific at least

In general I would create a datasheet, where I stored past invoices, so you can return to these, instead of deleting them, but if that is your wish, then that is the easy part.


LVL 22

Accepted Solution

Ejgil Hedegaard earned 250 total points
ID: 39860095
Format all input cells as unlocked.
Make sure that all other cells are locked.
Then loop all cells in the UsedRange and clear contents for not locked cells.
The worksheet can be protected or not.

Sub ClearNotLockedCells()
    Dim ws As Worksheet
    Dim cel As Range, celM As Range
    Set ws = ActiveSheet
    For Each cel In ws.UsedRange
        If cel.Locked = False Then
            Set celM = cel.MergeArea
        End If
    Next cel
End Sub

Open in new window

LVL 33

Expert Comment

by:Rob Henson
ID: 39864659
Alternatively, set the Invoice file as a template by saving as .xlst and then when people use it to create a file it will be blank and no need to clear data.

Rob H

Author Closing Comment

ID: 39872061

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Read top line from CSV file 14 55
modify formula for range changes 8 28
Excel to show a dynamic Picklist at level2 2 21
need help to look for 16 39
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

739 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