Prefill cell with data and selecting cell if zero

mbesspiata

Board Regular
Joined
Aug 28, 2009
Messages
100
I have two questions on this post. I have to enter numbers into a cell for scripting into another program but the other program requires the numbers to be preceeded with a V00. Can I do some formula in the cell to where I can just type the number and it automatically places the V00 in front of it?

Second question is if a cell is blank, I want to pull in a specific date from another cell. What formula would I use in cells to say if this is blank, use this cell data?

Mike
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
This will solve your first problem.

Alt+F11
Double click your sheet on the left-hand side.
Paste this on the right hand side.


Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Set rng = Range("A1") 'put your cell or range in here that you want this to apply to
If Not Intersect(Target, rng) Is Nothing Then
    Target = "V00" & Target
End If
End Sub
 
Upvote 0
The problem with the second request is that as soon as you type into a box it removes the formula. So, you could have by default a formula which references another cell, or today's date, for example. Then the user can type over it with their own data if they want?

=A1
=Now()
 
Upvote 0
The alt f11 opens the macro folder. Where on the left side of my spreadsheet do I double click?
Am I pasting this into the spreadsheet or into the new macro?
 
Upvote 0
Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Set rng = Range("A1") 'put your cell or range in here that you want this to apply to
Application.EnableEvents = False
If Not Intersect(Target, rng) Is Nothing Then
    Target = "V00" & Target
End If
Application.EnableEvents = True
End Sub

Use this ^^^^^ instead.

Alt+F11

On the left side of the screen you'll see a list of your various sheets. Double click the sheet that you want this code to work on. On the right side, after you have double clicked the sheet, you'll see a big white area. Paste the code there. Save. Use.
 
Upvote 0

Forum statistics

Threads
1,214,539
Messages
6,120,100
Members
448,944
Latest member
SarahSomethingExcel100

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top