I am trying to make a button so I can recalculate a certain area inside of my worksheet. However after having looked at several tutorials I cannot figure out what I am doing wrong.
Here is my code:
Sub ReloadPlanet()
Worksheets("Sheet1").Range("E9:H27").Calculate
End Sub
Any feedback as to what I am doing wrong?
edit
Here is a bit more detail on the sheet itself:
Each of the commands I want refresh are VLOOKUP commands
Related
Hi I am kind of new to VBA and i can't seem to find what i am looking for.
What i want to make is a macro that links to another page in my workbook that refers to data in a certain cell.
from certain datapoints i have a cell set up that as everything is filled in it gives the name of the page i want to link to (lets say "overview_Oct_2020" by filling in the month and year in other cells), and when running the macro go to that.
I seem to totally blank on how to do it. I made a =HYPERLINK() version pretty easily, but i want to change that to a button, hence the reason for a macro.
so technically i want to make a button with a macro that goes to [TEXT IN CEL A1]!A1
Put this macro in a standard module and assign it to a button on the worksheet
Sub link()
Dim textInCelA1 as String
textInCelA1 = Range("A1").value
Sheets(textInCelA1).Activate
Range("A1").Select
End Sub
I am looking for the best way to "link" two worksheets together. I have a main worksheet where information and data is added and then I would like to have two basic worksheets that draws columns from main spreadsheet. Whenever changes are made to the main sheet, they will also occur in the other two sheets. I was thinking of trying to activate a macro which automates hitting ctrl or shift and the two tabs like the below
sheets (Array("Main", "Summary")).select
But this failed to work as well. Its too much information for vlookups or anything like that so if anyone knows a way to have changes that occur in one sheet effect multiple other ones it would be much appreciated.
Thanks!!!
You have the worksheet.Change event for that. Something simple like the following:
Private Sub Worksheet_Change(ByVal Target As Range)
ThisWorkbook.Sheets("sheet2").Cells(Target.Row, Target.Column).Value = Target
End Sub
Will copy the value on every cell change from one sheet to another (the code goes in the sheet's private module).
I have a question about freezing certain cells. But first let me explain the situation.
I have made a search box in my excel sheet and when you search for a letter or word; the results show up in cells below the search box. Now I want to freeze those cells, so that wherever I go in my sheet. I can always use the search box and see the results.
The cells for the searchbox and results are B2:B25. Those are the ones I want to freeze. Also the only sheet I want to use this on is the sheet "Reading". On the rest of my sheets I do not use a search function.
So my question(s) is : Do I need to put the code inside a module or on that sheet, and how do I do this?
Now I have tried the following
Range(Cells(2,2), Cells(25, 2)).Select
ActiveWindow(or maybe Reading?).FreezePanes = True
Inside a module. But it did not work and I do not know what else to do.
Any help is much appreciated! Since I am very new to VBA.
Almost there. Problem is that the 'range' and 'cells' needs to be directed to the 'Reading' sheet, like so:
Sheets("Reading").Range(Sheets("Reading").Cells(2,2), Sheets("Reading").Cells(25, 2)).Select
ActiveWindow.FreezePanes = True
but if it always is B2->B25, why not use:
Sheets("Reading").Range("B2:B25").Select
ActiveWindow.FreezePanes = True
This should work. Select is not very desirable, because it is very slow, but in this case, you need to (as far as I know).
EDIT
BTW, you can do this from within a code module or from within a sheet, but if you choose to do it from within a sheet, you cannot select another sheet. So just use the range.
EDIT 2
whoopsy, typo corrected. 'Sheet' should have been 'Sheets'
I use MS Excel 2007 to make Bills and Quotation. Often I need to reuse previous quotation.
After I copy a quotation and paste it to new location the row height needs to be readjusted for each row.
is there any solution to this?
I'm not totally sure if this is what you are after. But have you tried something like this?
Private Sub Worksheet_Change(ByVal Target As Range)
' Here you enter a matrix with the cells you want to trigger a Autofit
' If you just want one column to do it, take Range("A1:A200")
Range("A1:C11").EntireRow.AutoFit
End Sub
This code gets the row-size auto-fitted everytime you change the value in the choosen cells.
It's hard to come up with a good solution when you do not give to much information.
Check here :
Excel Worksheet_Change Event not working if my code didn't help you.
Best Regards
I have the following VBA code, which should show a dataform from another hidden sheet.
Sub CoverageBssEntry()
Application.ScreenUpdating = False
Sheets("myhiddensheet").Select
Range("myTable[#All]").Select
ActiveSheet.ShowDataForm
End Sub
When I run this, the data form does not containt the labels and inputboxes of this table.
Any help is really appreciated, because it is driving me nuts! My only other option is to spend time to build custom made user forms, while this would do perfectly.
You cannot select a hidden sheet. And anyway the .Select statements are not necessary
Try
Sheets("myhiddensheet").ShowDataForm
The fix is to use:
ActiveSheet.Cells(x,y).Select
prior calling the .ShowDataForm, works like a jiffy!
I think there are genuine constraints with the ShowDataForm command. It works fine if invoked outside of VBA while in a specific range. But once coded into VBA, it will only return the form for the first table in the referenced worksheet, even if a macro was recorded to perform that action.
I cannot tell why. Maybe because the showdataform event is tied to the worksheet and not to the table or list selected when it is called. Sorry guys. Maybe microsoft will improve this in the future.