The following sub to create and name wsheets results naming the new sheet with the value of "A9" only, but what I want to name the new sheet is "A9" + "B9".
Sub CreateWorksheets()
Dim newSheet As Worksheet, itemSheet As Worksheet
Dim cell As Object
Dim itemrange As String
Set itemSheet = Sheets("BIDFORM")
Application.ScreenUpdating = False
itemrange = "A9:B9:" & itemSheet.Range("A9").End(xlDown).Address
For Each cell In itemSheet.Range(itemrange)
If SheetExists(cell.Value) = False Then
Sheets.Add Before:=Sheets("BACK SHEET"), _
Type:="C:PathFile"
Set newSheet = ActiveShee
newSheet.Name = cell.Value
End If
Next cell
Application.ScreenUpdating = True
End Sub
I'm trying to create a new function in Excel and for some reason the syntax is incorrect and it won't let me use it in the sheet. I do not know what I'm doing wrong so any help would be appreciated. This function will allow me to interpolate the term structure of interest rates between dates (I think) My code is
Function INTSPOT(spots, year) 'Interpolates spot rates to year Dim i As Integer, spotnum As Integer spotnum = spots.Rows.Count If Application.WorksheetFunction.Count(spots) = 1 Then 'Single rate given INTSPOT = spots Else 'Term structure given If year = spots(spotnum, 1) Then INTSPOT = spots(spotnum, 2) Else Do i = i + 1 Loop Until spots(i, 1) > year INTSPOT = spots(i - 1, 2) + (spots(i, 2) - spots(i - 1, 2)) * _ (year - spots(i - 1, 1)) / _ (spots(i, 1) - spots(i - 1, 1)) End If End If
I'm not sure where my syntax is wrong, and I can't think of what to google to learn more about the possible options I have when creating and declaring the value of variables.
I am simply trying to define the variable aWB as a workbook, whose name is found in cell B6 on the worksheet named "Start" in the workbook named "DW1". This seems to make sense to me, but I am not typing it correctly.
Code: Dim aWB As Workbook Set aWB = Workbooks("DW1.xlsm").Worksheets("Start").Cells("B6").Value
I know that I cannot automatically assign UniqueCount the value of that formula. How would I format the line such that I can indeed assign UniqueCount the row value of that line?
However, when I try this with a different formula =IF(ISNUMBER(SEARCH(C2,H2)),"REPEAT","SAFE"), I'm getting a compile error: Expected end of statement with this code:
The error message highlights the word REPEAT. I suppose it's something with all the quotes throwing off where compiler thinks the end of the formula should be.
I trying to populate cells with a correlation function using VBA, I have set up dynamic references/arguments for the fuction to take on however I just can't get it to work. Currently instead of populating the formula into the cell, it's just populates it as a string based on what's entered below =correl(Ystart &":"& yend, xstart&'":"'& xend").
FYI - The correl function takes on two ranges,. I've predefined these below.
I would like some help from someone on this subject if possible. I am running a stats report in a workbook where each member of staff have their own running totals of how much work they do and how much of that work is incorrect (per week). I have worked out that if I use the following:-
I get the total amount of work. To explain the above, it returns the amount of times a date appears between two dates i.e B95 is week commencing date and C95 is weekending; therefore giving the total amount of work in that period.
What I am struggling with is that I need a formula to look at the above date range and then look at another column that has either a ‘Y’ or ‘N’ (for yes or no) and for the formula to count how many N’s there are (thus how many in that given range there were)
It appears to me quite a small ask for Excel but I can’t seem to get it to work.
I´m writting a macro. It works find until a certain point. When I want to change some outputs of the macro without changing the syntax, it display an error mesage while runing the macro. It says Else without If. Which is quite disturbing because the Else was not creating any problem before. Here is my macro before I changed the conditions (this one work nicely)
Sub Copy_Sheet_Beta() Set wba = ActiveWorkbook On Error Resume Next If IsWorkbookOpened("Projekt.xls", "C:Documents and SettingsfrederikSkrivebordRedd Barna") Then Workbooks("Projekt.xls").Activate 'In case open, just activate "Projekt" Else Workbooks.Open Filename:="C:Documents and SettingsfrederikSkrivebordRedd Barnaprojekt.xls" End If Set wb = Workbooks("Projekt.xls") wb.Activate If Not SheetExists(wba.ActiveSheet. Range("C1").Value) Then MsgBox "overall doesn't exist!" Else........................................
is it possible to write Range("A1:H6") without the string inside the range brackets? i'm trying to do is pass numerical column values into the Range function, and i'd rather not make a mess using the CHR function (CHR(65) = "A", for example).
I thought I had this cracked last month when I ran a set of reports using some code dependent on using advanced filters to first create a unique list to loop through and then to create a list of all entries in a list for each unique entry. The idea being that I extracted all the data for each unique entry in the list and saved that to a new workbook, named after the unique entry.
However, this month I'm totally flummoxed again. I can't seem to get even the first part, creating a unique list, to run.
I have a sheet with several thousand rows of data with maybe 25 columns. I have the following code to try to extract the unique entries in the 2nd column, column B and store them in the same worksheet in column AD, to use when looping through the list.
VB: With ActiveSheet .Range("AD1").EntireColumn.Delete .Range("A1").CurrentRegion.Columns(2).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Sheet1.Range( _
I am trying to write a sum formula using Indirect so that the end-user can enter the names of the sheets in B1 & B2 (the values are always in cell F5 on each sheet). I thought this would work but it is throwing a REF# error.
I have the following code to transfer data to another sheet, but there are 2 issues with it:
1. I want to just paste the values, but every code I have tried has had object or syntax errors that can't seem to be fixed
2. If I run the macro a second time, it overwrites what was pasted the last time the macro ran. My code looks like it should look for the next empty row in the range, but it doesn't seem to do that.
What is the correct syntax to do the above. Here is the code:
Sub Update()
Dim c As Object Dim rngA As Range Dim cc As Object Dim rngAA As Object
'Check every cell in the range for matching criteria. For Each c In Sheets("OpenGen").Range("F9:F208")
This line fails, is Method Range Global error.... What is wrong w/ this, and how should it read?
If Range("D", i).Value = "Need Parent" Then 2nd Question- The following line is my normal method in doing a simple For Next Loop. What is the difference between using this one, looping through the cells and the first one referring to a Range for the loop?
I am wondering if using an "if" statement or a case statement would be good ways to check two worksheets in two different workbooks to see if their names match? I could use some help correcting my syntax too:
For 1 to ws.count If Worksheet("one").Name = Worksheet("two").Name Worksheet("one").Range("A1:G84").Copy Worksheet("two").Range("A1:G84").Paste Endif Next ws.Count
I'm working on a workbook that will track staffing patterns.
The workbook has three worksheets: Sheet1 "RCS", Sheet2 "HCT' and Sheet3 "Hidden". I've attached the workbook to this thread. The password for the form is "j".
On Sheet3 "Hidden" I have two tables that are set up to collect the SUM of columns on Sheets1 "RCS" and Sheet2 "HCT". I'm finding the SUM of each range by way of the background color. I've set up the following formulas and when the "data collection tables" are in the same worksheets as the original information, the formula's work perfectly:
The following functions are pulling data from Sheet1 "RCS" and placing them into a table in Sheet2 "Hidden"
[Code] ........
The following functions are pulling data from Sheet1 "RCS" and placing them into a table in Sheet2 "Hidden"
[Code] .......
I have two more functions that aren't working due to the fact that the source values are percentages and NOT plain numbers. The above functions work great for SUM but not for percentages. EXAMPLE--Let's say, 3 sub percentages it gives me the SUM of the 3 percentages (i.e. 85% + 100% + 100% = 285% instead of giving me 95%.
[Code] ........
How might I use the following functions to find the average of the source fields instead of the SUM?
I have a range that I named. Let's say that range is called "RangeX". Let's say RangeX is defined by B2:E10
I have a series of formulas that give me the row and column numbers of the starting and ending cell of a subset range I want to create within RangeX. Let's say the starting cell is defined by (1,1) and the ending cell is defined by (3,4) within RangeX. Translated, the starting cell would be B2 and the ending cell would be E4.
How do I create a subset range using the starting cell (1,1) and (3,4) in VBA? I would like to use the row/column reference as RangeX itself could move around.
I have a workbook with two sheets. The first sheet is the data sheet.
Data Worksheet A B C D colA colA,B colA,B,C colA,B,C,D 104 20 21 CR10600S 104 10420 1042021 1042021DUS 104 20 21 CR10600SX 104 10420 1042021 1042021DUS 104 20 21 CR10603S 104 10420 1042021 1042021DUS 104 20 21 CR10603SX 104 10420 1042021 1042021DUS 104 20 22 CR49605S 104 10420 1042022 1042022HKZ 104 20 22 CR49605SX 104 10420 1042022 1042022HKZ 104 20 23 CR39601P 104 10420 1042023 1042023SPR The next sheet is where the magic happens. Separate this worksheet into two sections. The reference section (column A and B) and the entry section (column E-G). Column D is a formula that will concatenate column E-G together. In the entry section any number of combinations can be entered. In the reference section I need to take the style number and reference it back to the data sheet. Then take the possible combinations from that style (column E and greater) and see if any of those combinations exist on the other sheet in column D. If so then say added....otherwise say needed.
"....In Pricing Sheet" is where I am looking to put needed or added or something like it. A B C D E F G STYLE …IN PRICING SHEET Concat DEPT MCL SCL STYLE CR10600S Added 1042021 104 20 21 CR10600SX Added 1042022 104 20 22 CR10603S Added CR10603SX Added CR49605S Added CR49605SX Added CR39601P Needed Any ideas on how to do this in formulas and without code? I have tried and looked into index, match, dget and lookup. I just don't think I am finding the right combination of formulas.
I am having problems with the following formular in that it does not return what I am expecting.
I have 2 columns of data that hold Y/N values and I would like either "Yes" or "No" to be displayed in Col C for the 4 possible combinations that the interaction of Y and N in columns A&B give.
The data is Col A:A = Y or N Col B:B =Y or N
The four possible combinations and outcomes are: Col A = Y & Col B = Y outcome in Col C = "Yes" Col A = N & Col B = Y outcome in Col C = "Yes"
Col A = N & Col B = N outcome in Col C = "No" Col A = Y & Col B = N outcome in Col C = "No"
The formular I have tried is: =IF(OR(AND(A1="Y",B1="Y"),A1="N",B1="Y"),"Yes","No")
However while three of the outcomes for the combinations are correct (N/Y, Y/N, Y/Y), the output for the N/N combination is incorrect and returns "Yes" instead of "No".
Just wondering if anyone has any ideas as to what is wrong with this?
I've created a spreadsheet to 'translate' number/letter combinations (sub-levels in the UK education system) into a numerical value. I looked up how to do this on google and, through a bit of trial and error, worked out that the lookuptable has to be in alphabetical order, etc.
My problem is when I enter in any of the 'P' values (see attached), it returns 0.5.
I have the following code, taken from an example off the web. But I would like to change the save path to just C/: rather than copy the save path of the original file...I would also like to not close the active workbook that I am working in....how can i achieve this?
Sub TwoSheetsAndYourOut() Dim NewName As String Dim nm As Name Dim ws As Worksheet
If MsgBox("Copy specific sheets to a new workbook" & vbCr & _ "New sheets will be pasted as values, named ranges removed" _ , vbYesNo, "NewCopy") = vbNo Then Exit Sub
With Application .ScreenUpdating = False
On Error GoTo ErrCatcher Sheets(Array("Copy Me", "Copy Me2")).Copy On Error GoTo 0 For Each ws In ActiveWorkbook.Worksheets ws.Cells.Copy ws.[A1].PasteSpecial Paste:=xlValues....................
I have two pieces of code in module 1 and module 2 respectively:
This code is meant to find the first row number that has a string value of "" in column A:
HTML Code: Sub Macro1() Dim cell As Range Dim r As Double Dim p As String For Each cell In Worksheets("stock in").Range("stockcode") p = cell.Value r = cell.Row If p = "" Then Exit For Else Next cell End Sub
BTW column A will contain formulas that evaluate to "" so I assume cell.value will = "" even if it contains a formula?
In the second module a sort is executed on the range based on the number of rows:
HTML Code: Sub Macro2() ' ' Macro2 Macro ' Call Macro1
My code is falling down because I think my variables arent scoped right or my code is in the wrong place. Also macro1 will eventually be executed from a button on a different sheet (I dont know if this will matter).
The whole point of this code is to get around the fact that if you perform A - Z sorts on cells that contain formulas those that evaluate to "" will be at the top leaving lots of blank rows before actual visible data.
I have a line of code that compares cell values with a variable.
Code: dim rmycell as range If rmycell.value = MyTarget then
This works fine when rmycell.value is empty or has a value. However, sometimes rmycell has a #VALUE! Error. When debugging the code I can see this error showing rymcell with a value of "Error 2015". The MyTarget variable is "abcdefg", so the If statement should resolve as
Code: If rmycell.value = MyTarget then becomes Code: If Error 2015 = "Abcdefg" then
Which should be a negative result. Except it isn't. The code that is conditional on a positive result runs whenever there is a #VALUE error, just as if the 2 values were equal.
In column H I have a list of numbers seperated by a space, the number of lines can change. In column L I have a list of numbers which can change either expand or retract.
I would like to check each cell in column H and if any numbers are not listed in column L then it/they should be shown in column G.
Example1 H2 shows 6 11, therefore cell G2 should show 11.
Example 2 H6 shows 5 6 9 11 therefore G6 should show 9 11
Sheet1 HIJKL1Container ID26 11 135 8 11 245 7 11 355 7 565 6 9 11 675 6 9 Excel tables to the web >> Excel Jeanie HTML 4
CTRL/END key combination should goto and select the last cell in a Worksheet. So for a Worksheet using Rows 1-4135 and Columns A-Z it should indicate Z4135 as the last cell My current worksheet uses these Rows and Columns, but CTRL/END indicates last cell as being AB4506. (Inflated by 371 Rows and 2 Columns)
Deleting the unwanted Rows or Columns, or "Clearing contents" of them does not affect the result given by CTRL/END which still shows AB4506.
How can I adjust/correct the last cell indication?
Usual work-around is to select the wanted portion of the worksheet and copy it to a new blank worksheet, but is there an easier way?