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

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.

Related

Conversion of regular index formula to macro

Can anyone explain to me how to convert the formula INDEX($C$1:$AD$1,MATCH($AE3,$C3:$AD3,0)) to a macro? It needs to only be run when I press a button. It does not need to be recalculated frequently. A single button click should fill all the values in the same column. It is okay if the destination cells end up only containing plain text.
I have included a screenshot of my Excel sheet. I marked the formula in the image.
Thanks!

VBA code to clear FORMATTING and leave plain text data in a chosen column in Excel

I need to create a button to add to Excel (2010 currently) that will strip all the formatting in that column and just leave plain text. Our current solution is to copy the data into Notepad to strip out the formatting and then copy it back in from Notepad. This works, but is inelegant and would be far easier if I could just create a button to do this within Excel itself. I've seen a few solutions posted but none of them seem to deal with a randomly selected column. Help!
The Range.ClearFormats method seems appropriate here.
With Worksheets("Sheet1")
.Columns(1).ClearFormats 'clear formatting from column A
End With
'for a manually selected group of cells
Selection.ClearFormats 'clear formatting from the cells currently selected
fwiw, the Clear Formats command is available on the ribbon through Home ► Editing ► Clear ► Clear Formats (Alt+H+E+F). You could easily add that command to the QAT rather than create a macro that largely duplicates the command and assign it to a custom button.
Excel already has a button on the Home tab:
Just select the entire column and click Clear Formats
Just to add to Jeeped's answer:
Using this code you'll clear the whole columns formatting (select a random cell, run this code and the whole columns formatting has been cleared)
Sub ClearColumn()
i = ActiveCell.Column
ActiveSheet.Columns(i).ClearFormats
End Sub

Data format in excel not changing from 1/1/2015 to 1-1-2015

In Excel 2010 , I changed the date using the Format cells options, when I change it and click ok, it changes in the cell, but when i click on the formula tab its still 1/1/2015.
I am using VBA to read the data from this cell, i don't want different display on different PCs
Can someone help?
Changing a cell's format will change the way data is displayed in the cell, but not necessarily the way data is displayed in the formula bar.
(there are some exceptions to this)

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

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