Solved

felds name in Excel

Posted on 2014-02-13
7
178 Views
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 ?

Tks
0
Comment
Question by:AXISHK
7 Comments
 
LVL 4

Expert Comment

by:Jorgen
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

Jørgen
0
 
LVL 4

Assisted Solution

by:Jorgen
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, Exceldoktor.dk 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
'---------------------------------------------------------------------------------------
ThisWorkbook.Worksheets("Sheet1").Range("B4").Select
Selection.ClearContents
    
End Sub

Open in new window


Best regards

Jørgen
0
 

Author Comment

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

Tks
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:Jorgen
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.

regards

Jørgen
0
 
LVL 21

Accepted Solution

by:
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
            celM.ClearContents
        End If
    Next cel
End Sub

Open in new window

0
 
LVL 32

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.

Thanks
Rob H
0
 

Author Closing Comment

by:AXISHK
ID: 39872061
tks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

895 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

14 Experts available now in Live!

Get 1:1 Help Now