Force Data Entry into another Cell???

martyloo

Board Regular
Joined
Sep 29, 2010
Messages
99
I have created a number of buttons which when pressed will all display a certain value into a cell.....

After I press a button and it displays the value into a cell, I want to be able to press another button which if there is data already in the cell (from the first button press) it will automatically put the value from the second button pressed into the cell next to it.

The reason I need this is because sometimes i may press the first button twice or the second button first so I will need the values to alternate between two seperate cells.

in other words if data is in one cell automatically put the new data in another cell

can you help????
 

Some videos you may like

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,684
Office Version
  1. 365
Platform
  1. Windows
Welcome to the board.

Can you post your code?
 

martyloo

Board Regular
Joined
Sep 29, 2010
Messages
99
at the moment, when the button is pressed it just displays a value into one cell. Thats as complex as it gets, im new to vba. I want it so if i press the button again or another button that is also assigned to display a value in the same sell - To recognise there is already a value in this cell so go to another cell.....

code so far is as follows:-

Sub Ace1_Click()
With ActiveSheet.Range("c10")
.Value = 11
End With

Which just displays the value 11 into cell c10 when the buttons pressed. If i press that button again I want the value 11 to go into cell c11.

any ideas?
 

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,684
Office Version
  1. 365
Platform
  1. Windows
Well below can be modified to:
Code:
Sub Ace1_Click()
If IsEmpty(Range("C10")) Then
  Range("C10") = 11
Else
  Range("C11") = 11
End If
Which will populate C11 if C10 is not empty
 

martyloo

Board Regular
Joined
Sep 29, 2010
Messages
99
so simple, wow thankyou so much.

I have been looking for this information everywhere trawling google and VBA for dummies, join this forum and get the answer in 5 minutes.

Fantastic!
 

Watch MrExcel Video

Forum statistics

Threads
1,109,149
Messages
5,527,098
Members
409,745
Latest member
CharlesAlsop

This Week's Hot Topics

Top