Show Cell Range on UserForm; then update - vba

I've been using a crude method to help the user update some cells - by having them in a sheet. Is there any way I can display the various ranges in a userform, one by one, then have the user update them, click a button and move onto the next one?
Essentially, can I have Excel automatically generate an input form based on a range? The process of updating and saving back to the sheet I can do; it's the production of the correct form that I can't.

It's possible to do this, but the only way I can think of is to make a userform that automatically populates itself based on a range passed in. This way you could have different macros in Excel that call the form to populate based on different ranges. I built a proof of concept Excel file for trying this, and it seems to work, the only issue I can think of being that you need to figure out a way to tell the user what input field is what.
I think what needs to be done is to add controls programmatically to a userform (I name the textboxes as the cell address it's going to populate) then when the form is closed loop through all the textboxes and populate the cells with the textbox values.
You can see what I did at:
https://my.syncplicity.com/share/uicgbs3rl0/InputForm.xls
I think all that would need to be done is for you to work out how to add labels for the textboxes, and make sure the form is resized based on the controls you add...

I am not quite shure what you are looking for, but you could insert a second sheet and use it as a "form". An other way could be a dialog box with an input field.
Either way, you present the cells you want the user to change one by one, using a vba-function. You implement a "previous field" and a "next field" button, so the user can step through the range of cells. If the user hits "next field", you save his input and take the next cell from a previous defined range of cells.
You could have a "config field" in which you define the range of cells you want to change.

This is pretty rough and old-fashioned but if you have the data in standard list format - i.e. column headers in the first row of your range and then one record of data in each row below - then selecting a cell within the range and going Data > Form will give you a crude input form with roughly the functionality you need.
You can also do this in VBA by calling the ShowDataForm method of the appropriate worksheet. Just select a cell within whichever range you need first. The macro will remain paused until the user closes the data form

Related

How can I check the time a cell was edited and set the time and date in other cells? Google script

I have spreadsheet and I'm basically going to use it for inventory tracking and management.
In one sheet I'll have an app on my phone fill a list when it reads
a QR code.
In the second sheet there is also a list with the
specific QR codes of each item.
I need to know when a cell in the first sheet has been updated and put that information in the following two cells.
I'm using this trigger to check if ANY cell in the document has been updated.
function cellEditTrigger()
{
ScriptApp.newTrigger('coolFunction').forSpreadsheet('awsomeSpreadsheetID').onEdit().create();
}
It works fine and it runs the 'coolFunction' function. However I can't seem to be able to get the time and date for the cells that have been edited and put that information in the next two cells.
I know I could use onEdit(e), but I still can't get the information from e.range and I would like my script to not have to be bound to the Spreadsheet.
Is there any way to accomplish this?

with a VBA userform, how do you populate a combobox with a different text and value?

I am trying to populate a VBA userform combobox with a named range, and I want the text value to display in the combobox for the user to select, but the value I want returned is the cell reference to the initial named range. That way it would point back to the named range, and if I change that text, it would automatically update all the references I have on the sheet that were entered by the form.
Right now I can get the named range to populate the combobox by iterating through the range, and using an .AddItem to give it the textual value, but then it just dumps that textual value into my spreadsheet, when instead I would like it to have the cell reference from the range that populated it.
The easiest way to do this is to create an Array(X,2) X being the number of items in the array. Then you put the String you want to display in Array(1,1) and the data you want in Array(1,2) then simply populate the combo box like normal. When you and use the array to reference which item they choose. They choose item 8, you know it is Array(8,2) If you need more help please post some code.
So, after more research it would seem that I am unable to directly accomplish what I want with the combobox. I ended up just looping through the range to fill the combobox with the textual values, and then when I submit the form, I looped through the same range of values, checked it if the submitted value matches one from the range of values, and if it does, then return the .Address instead of the .Value, and that gave me the cell reference I was looking for. Too bad the combobox doesn't work more like a real html select menu, it would have made my life a little easier, but in the end I was able to make it work, it just isn't as clean as I would have liked.

Copy data from one part of a userform to another automatically

I am trying to work with an Excel form using VBA that I have customized (I found the original on the web).
I have two tabs: one is called Planning-Deleted, the other is called Planning-Deleted Data. All the data that I enter in the first tab is copied to the second tab when I press a command button called Add to Database.
Is it possible to skip the command button altogether and record the data entered in cell D5 and D6 directly in the second tab and clear these cells for the next records? I have no knowledge of programming and I would appreciate as much clarity and specificity as possible.
If more details are needed, please let me know.
You'll need some trigger to cause the copy operation to happen, for example:
Using the 'Change' event, you can trigger some action any time some value is entered into a sheet:
Private Sub Worksheet_Change(ByVal Target As Range)
Sheet2.Range(Target.Address).Value = Target.Value
End Sub
This code will copy any data entered into the first sheet into the same cell on the second sheet. 'Target' in this case is the cell where data was entered.
I'm not sure if this what you want though, since you also want to clear the cells after the copy. Can you describe when the copy-and-erase should occur, if not from clicking a button?
Also, your question doesn't seem to match your question's title. Can you clarify a bit what you are trying to accomplish?

Cell reference in an Excel Macro

I have a macro to write, quite simple.
It just pulls numeric values from a Database and pops them into certain cells.
Problem is, I want the layout and design of the worksheet to be able to be changed without a care of the underlying macro. So obviously the cell references will change, for the cells that I need to populate with data.
Is there a way to mark a cell - say with "VALUE1" - in the background, and then reference that cell by using "VALUE1" - without needing to know its exact Cell position? So that its value can be updated - wherever it is on the Work Sheet?
Is there a TAG property or something that could be used? Although a function would have to be written to search through all the TAGs of every cell, but that is OK.
Any ideas?
I think this could be a bonus for any Macro developer :)
Office Documentation: Define and use names in formulas.

Take Textbox input and move to a specific cell.

I'm writing a macro to pull various data from an Excel sheet and put it in a more usable order. A problem I've run into is that one section of the data I want is contained in a textbox. I'd like to pull the data out of the textbox and have it all pasted into a cell, A100.
The textbox is always called ActivityA.
try this
Cells(100, 1) = ActiveSheet.Shapes("NameOfYourTextBox").DrawingObject.Text