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´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........................................
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 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 have a range, A1:A10 that I want to sum, min, and max. I want to ignore any text or #DIV/0! values in this range. I know how write the formulas except how to ignore the text and cell errors. Can someone steer me in the right direction?
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 want to find the number of times the 23rd happens between a range of dates.
Let's say I invoice a customer on 5/23/12 (Column C) and I've sent an invoice every month on the 23rd. I want to count how many invoices I've sent during the past few months. I need a formula which tells me how many times the 23rd of the month happens between 5/1/12 (in column A) and 12/15/12 (in column B).
I thought it might be =COUNTIFS(A1:B1,DAY(C1)) but that formula is for counting cells in a range.
I found formulas for counting the specific day of the week (like Tuesday) and for counting the number of cells containing a number, but not this.
How do I disable a range of cells when a numerical limit is reached?
Here is the scenario:
I have two worksheets, one called “Items” which contains a list of Items and their weight. The other sheet is called “Container” and displays a Type of container in cell B2, the weight capacity of that container (the numerical limit) in cell C2, and a range from B5 to B14 that needs to be filled out by an end user. The items in B2:B14 are chosen using Validation, form the Items sheet. The weight is brought in via a vLookup, and the total weight is calculated as items are added.
My problem is that I have yet to find a way to “disable” any extra cells in B5:B14 once the weight limit is reached, and clear the last cell data was selected for, all without destroying the Validation for the cells in range B5:B14.
I have tried many different things in the Worksheet Change Event, but none have yielded the desired result.
I have a formula that counts all instances of the letters a, b and c in a range and assigns them a value of 1 unless they are in the M column in which case a, b or c counts 4.
This worked well but now I need to modify the weightings across this range. My new goal is to count all instances of a,b and c in the range J2:AB2 but have M column a,b, c's = 2 and N:R column a,b,c's equalling 4. Letters other than a,b or c count as 0.
I would like it to scan an entire column (column E) for rows of data that fall into a range of numbers chosen by the user (like maybe a list box or combo box in sheet 1) for example a number greater than or equal to 8 but less than or equal to 15 and copy all of the rows and columns of data across the entire sheet that fit the range from sheet 1 to sheet 2. I would like to use a separate list or combo box for the min and max values in which to search as seen in the example sheet 1 attached. I have tried the autofilters, custom filters and macro recorder with no success as it seems the filters do not like ranges of numbers.
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
Is anyone aware of some way to use the " dynamic named range approach" to only select the cells with numerical values in a column and name this range?
I've looked at the examples on this site but can't find any solution to this particular problem although I have a feeling that this should be possible.
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 single column of numerical values that may repeat many times within the column.
I require a flexible Formula: Use an Input Cell for the specified and changeable Percentage(s) %. Column may be filtered – so only take into account Visible Filtered Cells.
The Formula will calculate and Return the numerical range of values that fall between the specified percentage % (using the Input Cell) e.g.; 70%.
The Formula should Return two numeric values: a Start Value and an End Value – NOT necessarily the minimum and maximum per se BUT the MIN and MAX of the values that appear 70% of the time in the column; therefore, taking into account Repeat / Duplicate values.
The calculated Results: the two numeric values will be returned to separate cells on a new Sheet.
Code: Dim Recurring_Total as Range With .Range("A" & Rows.Count).End(xlUp).Offset(,2) Set Recurring_Total = .Range("A" & Rows.Count).End(xlUp).Offset(,2) .Font.Bold = True End With
I'm doing somthing basically wrong here but i'm not sure what, everything seems to work as planned except in each case where a value is assigned the value isn't actually assigned. any ideas?
The basic objective is to convert a list of numbers (1 to 3 digits) to the format "000-" i.e. all three digits with a hyphen at the end.
I have a while loop in which I'm updated information in 2 separate worksheets. I'm using the With-block statements separately to update each, but after the 30th iteration (and it's always on the 30th), the VBA code halts and get the "method 'value' of object 'range' failed" error message pointing to a line with the code as follows:
With Sheet1 .Cells(lngRow, 9).Value = intMonths End With
where "intMonths" is an integer variable which I'm populated properly, and "lngRow" a long variable. When I debug both variables have proper data in them, and I have no idea why this is bombing.
Dim c As ADODB.Connection Dim r As ADODB.Recordset Dim sq As String Set c = New ADODB.Connection
It's the standard ADO example used in this forum many times. Obviously there is some type of issue when the records are returned. I know that it isn't an issue with the number of records returned. It can return 30,000 fine but a few hundred may return this error. It's kinda random.
I have a range object called tbl which consists of a number of rows and columns of numbers.
I have another range object called e that is the total row just beneath tbl. I want to sum up the total of each column within tbl and put the result in the appropriate cell within e.
I can do it using a for/next loop as shown below but there could be 10,000 rows and a hundred columns in my range which woulod probably take forever. I know there must be another simple way to do it but despite racking my brains and trying various things I can't get it. I'll be very grateful for any assistance.
My current solution is as follows. (e is selected).
'Calculate totals and display them
For g = 1 To tbl.Columns.Count ' the number of columns h = 0 ' Holds the column total For f = 1 To tbl.Rows.Count - 1 ' The number of rows h = h + tbl.Rows([f]).Cells(g).Value 'add the cell value Next e.Cells(g).Value = h ' Display the column total Next
Sub test() Dim rng, dest, c As Range Dim result As String Worksheets("sheet1").Activate Set rng = Range([a1], [a1].End(xlDown)) Set dest = Range("d1") result = "" For Each c In rng result = result & " " & c Next MsgBox result dest = result End Sub
the penultimate code statement "dest=result" does notwork the value of "result" is not entered in "dest" though no error comes up if I use "dest.value=result" it gives error "object required" If I use "range("d1")=result" it works.what is the theoretical mistake.