Referencing A Cell In A Worksheet.
Jul 25, 2006
I used to think I was moderately intelligent. Certainly, I thought I knew my way around a computer. Then I got the bright idea to try and learn VBA. Since then every attempt I've made in trying to produce the most basic of code results in mad fits of rage and me wanting to slit my wrists. I've read half a textbook and I keep trying to write simpler and simpler code to get some sort of result, just to give me the drive to carry on but no matter what I try it always goes completely wrong.
So before I stick me head through the computer screen, here is today's attempt. I want to select a worksheet. I then want to copy the contents of cell A2 down to A1200.
Private Sub CommandButton1_Click()
Sheets("Calls Outcome").Visible = True
Worksheets("Calls Outcome").Activate
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:A1200")
End Sub
I’ve stepped through the code and I get an error on “Selection.AutoFill Destination:=Range("A2:A1200")”. After spending several eight-hour days trying to get something out of VBA I have zero energy and zero patience.
View 6 Replies
ADVERTISEMENT
May 3, 2013
coding a VBA macro for one of my workbooks, in which I need to be able to hide/unhide various rows in one worksheet depending on the value of a cell in a worksheet elsewhere in the workbook. The rows start off hidden by default.
As a simplified example:
Worksheet1 has a cell that has option "Set 1," and "Set 2." Worksheet2 has two sets of rows (say, 20:30 and 40:50) that need to be hidden/unhidden depending on the cell in Worksheet 1. These are hidden to start with!
So if Worksheet1's target cell says "Set 1", then on Worksheet2, rows 20:30 would stay hidden and rows 40:50 would be revealed, and then if the target cell says "Set 2," then on Worksheet 2, rows 40:50 would then be hidden, but rows 20:30 would then be revealed.
I was thinking of using something like this:
Rows("20:30,40:50").EntireRow.Hidden = True
If Target.Address="'Worksheet1'!A1" Then
If Target.Value = "Set 1" Then
Rows("40:50").EntireRow.Hidden = False
Else
Rows("20:30").EntireRow.Hidden = False
End If
End If
I think this might work, but every time I try to run this I get various errors, like not referencing my target cell correctly.
View 5 Replies
View Related
May 6, 2008
Is it possible to have a tab named by referencing a cell within a worksheet?
View 9 Replies
View Related
Mar 24, 2014
I am working with a worksheet that has some cells merged e.g. A1 and A2 are merged together as 1 cell. I am using cell offset to reference values from the worksheet assign them to variables then populate another worksheet with their respective values. I noticed that cell.offset(row,column).value is not retrieving a value when merged cells are mixed with non-merged cells within a given row. Is there another method/function I can take advantage of here?
View 1 Replies
View Related
Apr 21, 2012
I have a workbook that contains 50 worksheets named 1-50. I need to add more worksheets. all the formulas in the worksheets always refers to the previous worksheet.
How can i make a copy of the worksheet named 50, name it 51 and have all the formulas in worksheet 51 refer back to worksheet 50?
View 1 Replies
View Related
Dec 19, 2008
I need to create a worksheet whose sole purpose is to return the values from every 17th row from another worksheet in the same workbook.
I have spent a few hours trying to research the correct answer and OFFSET comes close but either I'm doing it wrong or it's not what I need.
I want to be able to drag the (every 17th row from sheet 1) formula down about 100 rows.
Assume A1 as starting place. I would prefer a formula answer as opposed to a macro or VBA.
View 13 Replies
View Related
Jun 24, 2009
way to reference the name of a worksheet in a cell, or even better, use a cell reference to dictate the name of a worksheet.
In other words, I would like to create a new sheet, and set it's name ='Sheet1'!C1 so that if I changed C1, the worksheet would automatically be renamed to whatever is typed in C1.
If that is not possible, I would like to have a cell be tied to the name of a given worksheet, so that if I renamed the worksheet, the cell would change accordingly...similar to the &[Tab] function used in headers/footers.
View 13 Replies
View Related
Dec 23, 2009
I have an XLS spreadsheet which updates cells through an ODBC connection to a database. The information is pulled across ok and 90% of the Vlookup and IF statements work. The problem arises on a summary page.
When i start off the summary page has cell references in numeric order to another spreadsheet and pulls back the information to 4 cells Across and 1000 Down. ='Campaign Responses - Cash Break'!A2
This is a spreadsheet that changes once the queries have run and a number between 1-1000 records are returned. However once the data has changed and the page refreshed. Not all the results have been pulled across to the summary pages. A few are there but the numeric sequence jumps from......
View 2 Replies
View Related
Oct 22, 2007
I have been having problems referencing text in a worksheet.
I tried cleaning it, didn'twork.
When I do T() some cells come back empty. I don't know why?
How do I get the text?
View 4 Replies
View Related
Dec 8, 2011
I have the formula:
=VLOOKUP(C10,'[Ticket Out Comparison Report.12.4.11.xls]TO'!$C:$O,10,0)
I want to do something like putting 12.4.11 in cell B1 and change the formula to something like:
=VLOOKUP(C10,'[Ticket Out Comparison Report.B1.xls]TO'!$C:$O,10,0)
View 9 Replies
View Related
Jun 4, 2009
I have a bit of a complicated one here so I have attached my book, its probably easier to undertstand the query by looking at the book. Hopefully somebody can help me out here.
I have 2 worksheets:
A results worksheet - this contains all category of results, each category has been given a specific sort id.
A foreign worksheet - this contains all categories found on the results worksheet with sort id = 7.
Now the complicated bit. The whole exercise is too pick up the correct exchange rate for the foreign category (sort id 7). each foreign type has a specific number at the end of its description in brackets e.g (3).
At the bottom of the "results worksheet" is a key which says what type of exchange rate to use for this type e.g. (3) Price of CAD 22.9 converted using exchange rate of CAD 1.9645 = £1.
What I need to do is on the foreign worksheet, it to recognise the number in the item description, keep it in mind then switch over to the "results worksheet" find the keys at the bottom of the page (the key is not necessarily in the same place all the time!!), match the number in the items description with the corresponding key and then find the exchange rate.
As i said very difficult to explain, since I reletively zero experience with this kind of work in excel. Luckily I been muddling my way through a work project gradually thanks to a forum member here. so i hope we can keep this up!
edit:
two restrictions in the way this solution can be done:
1- Results worksheet can not be modified, but it can be referenced to using INDIRECT, and you can make any number of modifications outside of the results worksheet.
2. Any solution must be automatic.
/edit
I have attached my workbook and highlighted the bits I need to fill and the picks I need to pick up.
Would be ever so grateful if some1 could show me the light here.
View 14 Replies
View Related
Aug 13, 2014
I want to export data from a set of named ranges in workbook x to another set of ranges in workbook y. The names of the ranges to be exported from and to are spesified in a table "Table_Export". Problem is I do not want to spesify in what sheets these respective ranges are located, seeing that I do not know the actual sheet names. But since the ranges are global it should somehow be possible to reference them in vba without referencing the respective worksheet?
The relevant code can be found below where either of the two 'commented lines within the if statement are what I want to accomplish.
Dim x As Workbook
Dim y As Workbook
Set x = ThisWorkbook
Set y = Workbooks.Open(Range("Export_to").Value)
Dim export_control As ListObject
[Code] ....
View 2 Replies
View Related
Mar 19, 2014
I've tested and I'm getting errors trying to reference a range in a specific sheet.
I want to sum a range for further calculation and can get this to work perfectly if I don't specify a sheet - but it sums the range in the wrong sheet as the code is within a With statement range:
[Code].....
I've checked that wsSumm contains the 'Summary' worksheet value and that's all fine, I've also tested the following:
[Code] ....
I've also tried replacing wsSumm with Worksheets("Summary") and Worksheets(1), but get exactly the same results, so no it's not a fault with the worksheet variable. Also tried using Application.WorksheetFunction.Sum, but again exactly the same results.
So, why I can't sum the range on the specified worksheet? Is is something to do with being inside a With statement for another worksheet - though I've not come across problems with this before...
View 3 Replies
View Related
Aug 19, 2009
Reference a worksheet that has not yet been created, avoiding the #REF! result?
The formula I have is correct, however the macro generates new worksheets throughout the month in which the totals sheet is referencing. The problem being that the totals sheet is referencing worksheets not yet created.
View 9 Replies
View Related
Jun 3, 2008
I have a spreadsheet which I'm using as a log-in front for a series of other workbooks. The usernames and passwords are stored hidden cells within a "very hidden" worksheet. The workbook is protected and VBA code itself is password protected.
In short no-one can directly view the passwords (unless the password to unprotect it all is known.
What I have found is that someone can use a formula to reference the cells containing the user details. "=a1" for example.
Is the a method hiding the contents of a cell from excel itself? I want the vba script to be able to see the value, but any "=a1" formulas to return a blank.
View 8 Replies
View Related
Jan 20, 2010
The workbook has a tab for each day, and there are variance columns. The tabs are named for the date, like 1.20, 1.21, 1.22, etc.
For example, the formula on 1.21 in D2 is simply =C2-'1.20'!C2
That works fine, but it's a time-consuming job to always change it. You have one sheet to copy many times for all the other formulas, but then have to re-name and change that variance formula on each worksheet.
Is there a way to reference the prior worksheet without using it's specific name?
=C2-'prior worksheet'!C2 would be nice...I could take my one sheet and copy it about 23 times for each workday, then copy that whole workbook to use in the subsequent months without making any formula changes.
View 7 Replies
View Related
Oct 31, 2011
I use Excel 2010, 64-bit-version with Windows 7. I have one workbook, where whenever I create a formula that references to one specific sheet, the Excel crashes and cannot be quitted even with Task Manager. I have to restart the whole system.
I do not have any worksheet events in either sheet. This is the same workbook that crashes if all cells are selected from the top-left corner of the worksheet.
I tried by deleting unnecessary COM add-ins but that didn't work.
View 1 Replies
View Related
Oct 19, 2012
I have created a userform that once the user clicks the okay button, the information is transferred to a worksheet template named 'PO Template', copied, and renamed. That portion works great. I then have code for a summary worksheet named 'PO Log' that finds the next empty row on the log and enters a formula referencing back to the newly created 'PO Form' (note - 'PO Form' is a variable as the actual worksheet name changes with the user input). The formula on the 'PO Log' references the 'PO Form' literally, which gives me a REF! error because there is no sheet actually named that. I've tried defining POForm in the code as a string so I can enter it into the formula code but I get an error because it's already defined as a variable. I've entered the sub routine for clicking the okay button below:
Code:
Sub OkayButton_Click()
'Make PO Template Active
Sheets("PO Template").Activate
[Code]....
View 2 Replies
View Related
Feb 9, 2008
I have a template i'm making that is full of formula references to sheets not yet in existance in the workbook. what i want to happen is this: My code imports data files, renames the tabs to 1, 2, 3, 4... The formulas i already have are set in the CONCATENATED tab.... an example of such a formula is: ='1'!$P2.
so this should work, and yet it doesn't. the sheet is imported as it should be, the tab is renamed to 1, and yet the CONCATENATED sheet still shows #REF for the cell value. if i click in the cell, click in the text bar and enter out, the formula updates. there apparently is no option that i KNOW OF (although i'm sure there is something out there that does...) that will update this without me entering into the text bar and entering out.
Question: how do i manually update all references once the sheets to those references have been imported?
View 2 Replies
View Related
May 18, 2009
I have a workbook with ~80 sheets. One sheet is a summary sheet containing data from each of the other sheets. The formula to display the data is pretty easy, but I need a function to copy the formula but increment the worksheet reference in each cell.
For example:
the formula in one cell is ='17'!$AI$6
The next cell should be ='18'!$AI$6
and so on...
I have about 12 columns like this, so I really don't want to edit each of them individually.
View 5 Replies
View Related
Sep 22, 2013
I am attempting to create a workbook that will keep an inventory of items in a catalog that I own and want to order (worksheet1). Ultimately an order form would be filled in(on worksheet2). I would like to have the entire row of data copied (from worksheet1)to the next open/empty row on the order form (worksheet2), if any cell in column C (worksheet1) has data.
I have attached the workbook : Catalog Orders.xlsx‎
View 4 Replies
View Related
Apr 19, 2012
I am using Excel 2007 in Windows XP. I am trying to change the worksheet referenced in a formula from the label of the worksheet to the index of the sheet. I want to use this macro in multiple workbooks, and the relevant sheets have different names but are all in the same position.
I used "record macro" to get the structure of my code. It gave me the line:
ActiveCell.FormulaR1C1 = "=SUM('8Nov11'!R[13]C[-4]:R[108]C[-4])"
I want to change that '8Nov11' to the 3rd worksheet from the left, so something like:
ActiveCell.FormulaR1C1 = "=SUM(ThisWorkbook.Sheets(3)!R[13]C[-4]:R[108]C[-4])"
I can't get this to work, and I can't find the syntax for this anywhere. I've tried with and without quotes, exclamation points, changing to A1 notation and using "Range," "Sheets," "Worksheets," "Item(3)", and many other combinations, but haven't gotten it right.
Most of the errors I get are "Runtime Error 1004: Application-defined or object-defined error."
View 3 Replies
View Related
Jun 15, 2012
I have a a spreadsheet that pulls user information from our corporate address book. I would then like to copy that data to another worksheet for additional data scrubbing. The problem I am facing is that, I can get the reference to work the first time but if I pull new data down, the destination spreadsheet now shows #REF!
I've tried using the below formulas but they all wind up the same way. ' Results' is the name of the spreadsheet I am making the reference to which has the dynamic data in it.
=Results!#REF!
=INDIRECT("Results!$B3")
=indirect (cell("results",B3)
View 1 Replies
View Related
Feb 12, 2014
we have a Excel 2010 worksheet containing multiple tables.
Table1
ColumnA ColumnB
1 Blue 12
2 Orange 14
15
11
3 Red 10
Table2
ColumnA ColumnB
1 Blue 11
2 Black 13
15
11
3 White 10
19
17
On a separate worksheet we want to calculate with the first worksheet's values.
For example: Calc1: Sum ColumnB IN Table1 WHERE ColumnA = Orange
How do we do such a calculation/formula?
View 4 Replies
View Related
Feb 8, 2012
Here is a formula I am trying to use to access another woorksheet to compare the values in J13 in each worksheet.
=IF(J13=INDIRECT("'"&$O$4&"'!"&"J13"),"â–¬",(IF(INDIRECT("'"&$O$4&"'!"&"J13")=" ","â–¬",(IF(J13=" ","â–¬",(IF(J13>INDIRECT("'"&$O$4&"'!"&"J13"),"â–¼","â–²")))))))
Where O4 contains the name of the first worksheet.
I want the formula reference [J13] to chage to J14, J15 and so on.
View 3 Replies
View Related
Nov 30, 2006
I'm dealing with a DDE link and have a cell that works when I type in the value =WINROS|AVEVOL!XOM . But I don't want to manually enter each value. So I have tried to use =INDIRECT("WINROS|AVEVOL!" & A2) where A2 contains the value 'XOM', but I get a #REF! error.
View 9 Replies
View Related
Jul 10, 2014
Warhammer Quick Reference Desktop.xlsx
Its on book 2.
I'm trying to reference the Cryptek total that I got in the previous area, and put that result into the grand total army point formula. When I reference the solution cell, or even copy and paste the very same equation into it, and then proceed to filter the referenced cells change...
The obvious solution that i thought would work is write =D45 next to Cryptek in the point value column, then if I filter it SHOULD maintain the information from D45 except it doesn't.
View 11 Replies
View Related
Mar 2, 2009
On the spreadsheet Im creating I am using cell referencing. The user will input data into the blank cells, and cell referencing will put them into another table. Then I add these using an IF(OR(ISBLANK formula.
However, the empty cells come through as 0's rather than a blank cell. As they're coming through as 0's, they're being calculated into the formula, and this is causing problems in my main table.
Is there a formula I can use to ensure that the empty cells being copied over do not give off any other value?
I tried to use a few different IF formulas to only let specific data go through, but it didn't work. I tried to have the blank cells produce a letter so that they wouldn't be calculted in the formula, but letters are also counted as measured values.
View 14 Replies
View Related
Jul 10, 2009
I have a row with month titles. I manually fill this with data as the year progresses. I need to automatically use the last month updated in the row in a formula. i.e. theformula is in one cell and calculates on the last figure in the row e,g, data is in january (say C3) - when I input Feb data in C4, I want the formula to automatically reference the last complete cell (ignore january data and calculate on Feb data), and so on through the year.
View 12 Replies
View Related
Jun 17, 2009
I'm trying to grab data from two sheets by first doing a match. The match works, but how can I now reference ws2 so that I can pick up data if this match is true?
View 2 Replies
View Related