Take Textbox input and move to a specific cell. - vba

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

Related

Excel table does not expand automatically when data added by vba includes a hyperlink

I have several excel workbooks that I want to consolidate in one excel table using the GetValue = ExecuteExcel4Macro(arg) method.
When data is added by the macro to the bottom of the table, the table should expand automatically and transfer formulas and formats.
This works pretty well up to the point where I want to add a hyperlink:
ActiveSheet.Hyperlinks.Add anchor:=ActiveWorkbook.Worksheets("Series").Cells(Irow, 3), _
Address:=fullpath, TextToDisplay:=GetValue(pfad, datei, blatt, "F3")
When including this line, the hyperlink is correctly entered, but the table will not expand. Without the hyperlink the table expands as supposed to.
Can anyone support here?
Thanks!
Use this code a line, before yours code :
ActiveWorkbook.Worksheets("Series").Cells(Irow - 1, 3).ListObject.ListRows.Add AlwaysInsert:=True

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.

How can I call a cell's contents in MS Excel?

I am using Excel to display a chart with some chart summary information in a textbox on top of it. The texbox must contain various data which is obtained from several cell formulas. To avoid changing the values of the text box manually everyday, I would like the textbox to be automatically updated by using the necessary cell values which are elsewhere in the Excel sheet.
What I would like to know is: Is there a way to reference the contents of several cells in a textbox?
Will I have to write a macro to do this? Or am I missing the trick altogether?
Any help would be much appreciated.
Many thanks :)
Insert text box
Click the text box, cut it, click your graph and paste.
With the text box selected, click the formula bar and insert your formula referencing the cell you want. Should be good to go.

How to AutoSum in Excel using VB.Net

Via VB.Net, is there any way to access the AutoSum feature that Excel has? I have a spreadsheet that I create and populate via a datatable using my application. I know how to sum based upon a predefined range (e.g., .cells(cnt + 1, 21).Formula = "=Sum(U3:U" & cnt & ")") but is there any way that I can just call a cell in my worksheet and have it AutoSum as if I was clicking the AutoSum button in Excel for that row? This would save me a lot of coding time based upon the logic my spreadsheet is going to need. Thanks for any help.
So are you trying to put the result of the sum of the complete row in the cells? Or do you want to put the formula "autosum" on the excel?
Either way you can do it by selecting that particular cell and then typing in the corresponding command on the value or formula field of that cell.

Show Cell Range on UserForm; then update

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