New Excel Forum

This forum has been moved to TeachExcel.com

Ask all future questions in the New Excel Forum.

ExcelKey

Using a button to change the cell that other buttons input data into.

Macros, VBA, Excel Automation, etc.

Using a button to change the cell that other buttons input data into.

Postby dpenner » Wed Nov 25, 2015 3:36 pm

I tried to verify that this questions was not already answered in another place on this forum but couldn't find anything relevant. Feel free to point me in the direction of another thread if it is already answered. I am trying to use one button to change the cells that other buttons are inputting data into. I attached a Example Workbook to better explain the problem. Thanks for taking time to help me out. :)
  • 0

You do not have the required permissions to view the files attached to this post.
dpenner
Rookie
 
Posts: 2
Joined: Nov 25, 2015
Location: Montezuma KS
Reputation: 0
Excel Version: 2013

Re: Using a button to change the cell that other buttons input data into.

Postby NoSparks » Thu Nov 26, 2015 8:43 am

For your big button this should work

Code: Select all
Sub Button1_Click()
    Dim ws As Worksheet
    Dim col As Long
Set ws = Sheets("Sheet1")
With ws
    col = .Cells(7, 5).Value
    col = col + 1
    If col = 10 Then col = 2
    .Cells(7, 5).Value = col   '<~~~~~ the current column stored in E7
    'to see which column is current
    .Range("B10:I10").Interior.ColorIndex = 0
    .Cells(10, col).Interior.ColorIndex = 6
End With
End Sub

For the part number buttons.... can you elaborate?
Is increment a total by 1 all that these buttons do?
I see part number 9012, are you going to have a separate button for each part and go looking for a particular button every time you do something?
Or are 5 parts all there is?
  • 0

NoSparks
Excel Hobbyist
 
Posts: 637
Joined: May 28, 2014
Reputation: 103
Excel Version: 2010

Re: Using a button to change the cell that other buttons input data into.

Postby dpenner » Thu Nov 26, 2015 3:15 pm

First of all thank you for taking time to read and reply. Yes all the buttons do is increment a cell total by 1. The buttons are actually going to be laid out over an image. It is a schematic. So for example if it was a house there would be a button on the front door, a button for the downstairs window, and a button for the upstairs window. If there was a city block of houses and a count of windows, downstairs windows, and upstairs windows was needed the first house would be location 1 then the part number buttons would be pushed according to the count of windows and doors. Then the big button would be pushed to move to location 2 or house number 2. And so on all down the block. Currently the cell that gets incremented is set in the code using range("a1").value=range ("a1").value +1 but am looking for a way to change the range here to match where the big button says us the current code. But I am new to vba and welcome a different approach entirely. Sorry for the long text post. Again thanks for the reply
  • 0

dpenner
Rookie
 
Posts: 2
Joined: Nov 25, 2015
Location: Montezuma KS
Reputation: 0
Excel Version: 2013

Re: Using a button to change the cell that other buttons input data into.

Postby NoSparks » Thu Nov 26, 2015 5:33 pm

If I understand what's wanted, hopefully, the attached file will be of assistance.
  • 0

You do not have the required permissions to view the files attached to this post.
NoSparks
Excel Hobbyist
 
Posts: 637
Joined: May 28, 2014
Reputation: 103
Excel Version: 2010


Return to Macros and VBA Questions

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 225 guests