Microsoft Office Forums


Reply
Thread Tools Display Modes

excel vba question

 
 
levy.pate@baesystems.com
Guest
Posts: n/a

 
      12-01-2005, 04:08 PM
Is there any excel vba code that will accomplish the following:

I have data entered in cells A1 thru E1 lets say (Name, Address, Zip,
Country, and Phone). What I would like to be able to do is enter the
requested information directly in the cells that contain the info as
mentioned above. Then if I make a mistake or delete the info I typed in
all together the original data returns. Example, In cell B2 it shows
Address, so if I type in my address the word Address is replaced with
my acutal address however, if I deleted my address the word Address
would reappear. Hope someone out there understands this and is able to
provide a solution if there is one. Thanks in advance.

 
Reply With Quote
 
 
 
 
Gman
Guest
Posts: n/a

 
      12-01-2005, 04:33 PM
This an Access newsgroup - this question should be addressed to
"microsoft.public.excel.programming"

But FWIW, you need to trap the event change on the sheet and handle
that. Place the following code in the Worksheet code module. (Note I've
created two constants so you can restrict the behaviour to between
specific columns.

Private Const ColToStartThisBehaviourAt As Integer = 1
Private Const ColToStopThisBehaviourAt As Integer = 5

Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range

'prevent any changes we make from firing events here
Application.EnableEvents = False
For Each c In Target.Cells
With c
If .Column >= ColToStartThisBehaviourAt And _
.Column <= ColToStopThisBehaviourAt Then
If .Row > 1 Then
If Len(.Value) = 0 Then
.Value = Me.Cells(1, .Column)
End If
End If
End If
End With
Next c
Application.EnableEvents = True
End Sub




(E-Mail Removed) wrote:
> Is there any excel vba code that will accomplish the following:
>
> I have data entered in cells A1 thru E1 lets say (Name, Address, Zip,
> Country, and Phone). What I would like to be able to do is enter the
> requested information directly in the cells that contain the info as
> mentioned above. Then if I make a mistake or delete the info I typed in
> all together the original data returns. Example, In cell B2 it shows
> Address, so if I type in my address the word Address is replaced with
> my acutal address however, if I deleted my address the word Address
> would reappear. Hope someone out there understands this and is able to
> provide a solution if there is one. Thanks in advance.
>

 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
export to excel question joseph Infopath Newsgroup 1 06-24-2008 05:45 AM
Powerpoint Text from Excel Question Colin PowerPoint Newsgroup 1 09-11-2007 05:20 PM
Hyperlink To Excel Question Mike Skibyak PowerPoint Newsgroup 0 08-16-2007 12:06 AM
question on excel GC Access Newsgroup 1 10-26-2004 06:07 PM
Export to Excel question Robert Judge Outlook Newsgroup 0 07-05-2004 12:39 PM



All times are GMT. The time now is 02:10 PM.