Range Is Not Working
Apr 13, 2009i dont know what's wrong with these lines:
View 3 Repliesi dont know what's wrong with these lines:
View 3 RepliesI'm highlighting a range and then sorting column F from Largest to Smallest. The macro doesn't sort it at all. Added my code tags.
View 1 Replies View RelatedI have a values in column C of stuff1, stuff2 and on down.
I have a value in cell A1.
I want to start in C1, and every Nth, where N is the value in cell A1, select and paste into column H.
My problem is that the selected cells don't start in C1, in fact, based on the value in A1, it starts in different cells in column C. AND, if i press the button twice, the returned values are different.
The code works up the If statement and I'm not sure why.
Code:
Private Sub SalesRedeemed_Click()
' Open SalesRedeemed Worksheet move to next month
Sheets("SalesRed").Select
Sheets("SalesRed").Range("B5").Select
If Range("B5") > 1 Then
Sheets("SalesRed").Range("B6").Select
End If
End Sub
My MACRO is used daily to copy data from several sheets resulting in a new sheet with a differing number of rows with every run. My problem is that I need to define this range of rows in order to do an AUTOFILL function.
I know I can use a cell to hold the row count using COUNTA. However, I cannot figure out how to then use the result of this in the range statement.
example using COUNTA within cell D100 produces a row count of 95
My MACRO needs to do the following:
A1 =Month(C1)
B1 =Year(C1)
Range("A1:B1").Select
Selection.AutoFill Destination:=Range("A2:B????"),
In the example I have attached there are two sheets, Details and DataTables. There are also a number of named ranges, both static and dynamic, that refer to data on the DataTables sheet. Most of the static ranges were added for debugging purposes. The tables have been shortened for this example.
On the Details sheet column A has a drop down that allows you to select the make of a device. Column B builds its drop down list based on what is selected in column A. The data validation in B2 uses a named dynamic range and the drop down does not work. The data validation in C2 used a named static range and the drop down works.
Column C will fill in the RU value based on what is selected in column B. Cell C3 uses named dynamic range and it does not work. Cell C4 uses named static range and it works.
I would like to used named dynamic ranges if possible so when data is added to the tables the named dynamic ranges will self adjust. Can what I want to do be done?
Dynamic Range.xlsx
I am trying to create a formula that if the date column falls between 01/01/2014-01/25/2014, it returns January as the value.
View 10 Replies View Relatedsee the attached spreadsheet, I am getting an error message with the attached formula
View 2 Replies View RelatedI have a problem using a named range as an arg to worksheet functions.
First, I create 2 end point names for the range, myStart, myEnd.
Then I create a named range myRange = myStart:myEnd
This formula in a cell works: SUM(myRange)
This formula doesn't: COUNT(myRange) . It crashes Excel, requests Restart.
But these work: COUNT(myStart:myEnd) and SUM(myStart:myEnd)
Why does SUM work for either set of args, but COUNT only works for one set?
Here is the F3, PasteList output:
mFirstCol =mFirstColMinus1+1
mFirstColMinus1 =COLUMN(Sheet1!$A:$A)
mInsertCol =COLUMN(Sheet1!$B:$B)
mLastCol =MAX(mFirstCol, mInsertCol-1)
mNumberCols =mInsertCol-mFirstCol
mRowEnd =INDIRECT(ADDRESS(1,mLastCol))
mRowRange =mRowStart:mRowEnd
mRowStart =INDIRECT(ADDRESS(1,mFirstCol))
what is wrong witht his code?
If Sheets("Workings").Cells(ExceptionCount, ColumnCount + 3).Value = 1 Then
Sheets("Allocations").Range(.Cells(ABIndex + 5 + week, (ColumnCount * 7) - 5), .Cells(ABIndex + 5 + week, ColumnCount * 7)).Value = ""
Else
End If
I know the If statement is working, but for some reason I can't fathom the line that removes the cell contents does nothing. I have tried ending with .ClearContents rather than .Value but that doesn't work either.
I've worked with Excel for many years and have just begun writing VBA in Excel 2007, so I am really stumped by this:
SR = 1
SC = 1
TR = 40
TC = 2
Worksheets("ChartData").Activate
' Works
ActiveSheet.Range("A1:B40").Select
' All of the following Fail w/1004 Error
ActiveSheet.Range(Cells(1, 1)).Select
ActiveSheet.Range(Cells(1, 1), Cells(40, 2)).Select
ActiveSheet.Range(Cells(SR, SC), Cells(TR, TC)).Select
At first I thought I had a bad install,
but this is happening on two manufacturer installed systems...
And I seem to be following the documentation for the use of Range with Cells.
Am I missing something?
I have a sheet of data that is imported from an external database. Depending on which report gets imported, the column count and column location will vary. However, the headers for the columns I need to work with are constant, therefore I create a named range for all columns, and reference the ranges as I work with the data and avoid hard-coded cell references. Therefore, the ranges are one cell wide, with up to 2000+ rows.
Here's my problem. I need to reference a sub-set of a named range, to get the min of the subset. I've searched this board and others, but can't find an example of this method. The code is within a loop, and the range subset location is determined by a count on another named range.
The data involves Tasks and Subtasks. Each task can have multiple subtasks, and each subtask has it's own start and end dates. I'm trying to determine the earliest start date and the latest end date for each individual Task so I can determine the total duration for the Task.
Here's the code that determines the cell range. This code is working.
d2 = WorksheetFunction.CountIf(Range("ASR"), Range("ASR").Cells(y, 1).Value) ' count number of tasks in this ASR, store in d2
The code that I can't figure out is below. The compiler can't figure out what I'm trying to do. (Neither can I!!)
d3 = WorksheetFunction.Min("Planned_Start_Date").Cells(y, 1), Cells(y + d2 - 1, 1).Value) ' Get the min Planned Start Date for this ASR
In english: Look in the Planned_Start_Date named range, and more specifically a certain subset of that range, and return the minimum date found.
I've tried several ways, none of which will compile. I realize the above code is way off; I include it to show how lost I really am!
Slightly off-topic: I'm fairly new to VBA, and am expected to create executive dashboards with the data. I've purchased Excel 2003 Power Programming with VBA and Excel Charts (both Walkenbach); Excel Programming 2nd Edition; Excel Edition of Using Visual Basic for Applications; and Dashboard Reporting with Excel, Kyd. These are all useful books, but I think they expect me to have a better understanding than I have.
how i can display different values using the Selection.FormulaArray, ok look at my
Dim mySheet As Worksheet
' On Error GoTo errors
Dim x As Integer
x = TextBox1.Text
Dim y As Integer
y = RefEdit2.value
Set mySheet = Excel.ActiveSheet
mySheet. Range(RefEdit1).Select
Selection.FormulaArray = "=multiplie_value(""" & x & """, """ & y & """)"
MsgBox Selection.FormulaArray
Now the function i call:
Public Function multiplie_value(valor As Integer, multiplo As Integer) As Integer
multiplie_value = Val(valor) * multiplo
End Function
thats an example. so the real question is i create a form, the user enter some values to search to a database, the user select an area(a range) where they want the data to be display, but i dont how to display that info that is coming from the database in the range that the user selected. The info displayed in the range should look like a tabular report, column headers, etc.
I am trying to compare vertical range "A" in sheet1 to vertical range "K" in sheet2 if they match to copy both rows and place in sheet3. I have tried the following but it did not work.
Sub Searching()
Dim sh1 As Worksheet, sh2 As Worksheet, sh3 As Worksheet
' create short references to sheets
' inside the Sheets() use either the tab number or name
Set sh1 = Sheets("Sheet1"): Set sh2 = Sheets(2): Set sh3 = Sheets(3)
[Code] ......
I often have problems with the cells range reference method. For some reason I get an error and can't tell why. Other times it works fine. Is this just an unstable method to use or is this completely wrong? I'm assuming I am using the wrong syntax. It is definetly the range reference causing the problem.
Dim cnt1 as integer, cnt2 as integer,cnt3 as integer
cnt1 = 2
cnt2 = 50
cnt3 = 2
dim myrange as range
set myrange = sheets("sheet1").range(cells(2,cnt1), cells(cnt2,cnt3))
I have no idea why it won't work. I'm basically searching a columner range of cells.
I am trying to create an equations that sums up a range based on matched dates. I have considered using an array, but that turned out to be much more work than necessary.
I have never used the SUMIFS before and having trouble, here is the equation I'm using.
=SUMIFS($F$2:$F$204238,MONTH(E2:E204238),"=month(referenced_range)")
*F2:F204238 is the range that needs to be summed up
*the month(referenced range) is in date form
*I was able to pull and evaluate all the data on it's own, but when using it in the sumif equation it gave me zero result so it must be a syntax error.
The formula is =SUMPRODUCT((Group="A")*(Project_Description="Long Term")*(Profile="B")*(INDIRECT(B9)="x"))
B9 through M9 have header text Jan_2012, Feb_2012...Dec_2012. Basically my aim is to get the above formula working before I drag it across so that the named ranges get picked up automatically from the headers.
Jan_2012 thru Dec_2012 are dynamic named ranges using INDEX (and not OFFSET as someone mentioned OFFSET is a volatile function).
The above SUMPRODUCT formula is giving me a #REF! error for the (INDIRECT(B9)="x") part. I know that because when I replace it with (Jan_2012="x") it works fine.
I realized while writing this that it may be because the named range in Jan_2012 is not the same size as that of other arrays. [but it is the same size - I've re-confirmed just now]
I am trying to use VBA code to take the relevant selections made to populate a Listbox and to insert them back into a cell range within the worksheet. The code I have come up with so far is:
Private Sub cmdApply_Click()
Dim i As Integer
Dim j As Integer
Dim StartRow As Integer
Dim EndRow As Integer
Dim StartCol As Integer
Dim EndCol As Integer
Dim temp
[code]....
The code should take any data within the listbox and insert the individual text into subsequent cells across the specified cell range. However, I keep getting various error messages. I have tried permutations of the code which do run but which copy a single entry from the listbox across the whole cell range!
Had been using this formula for almost 3 years, recently the formula didn't work properly as the range goes down halfway only instead of to the last data in the column. I'm using Excel 2010 now.
=Sheet1!$A$2:INDEX(Sheet1!$A:$A,COUNTA(Sheet1!$A:$A))
I am trying to display a message box for the user if there is "agency" in cell o8 but nothing in p8... I tried the following code but it doesnt work..
If Range("o8").Value = "Agency" And Range("p8").Value = "" Then
MsgBox "Please provide name of agency in cell p8"
Sheet9.Shapes("cross").Visible = True
Else
I have a workbook in excel 2003 which I had been running the following macros (listed below). We recently upgraded to Excel 07, and neither are working. When I try to run them, the "debug" option highlights the following line in the sort macro "Range("A2:z" & lastcell).Sort key1:=.Columns(1)". This is driving me crazy, as the macros worked perfectly under the older version of Microsoft. Is there an issue with crossfunctionality between '03 and '07'.
Private Sub Worksheet_change(ByVal target As Excel.Range)
If target.Column = 1 Then
ThisRow = target.Row
startRow = 1
i = 1
Set ws = ActiveSheet
maxRow = Cells.SpecialCells(xlLastCell).Row
maxCol = Cells.SpecialCells(xlLastCell).Column
ActiveSheet.UsedRange.Interior.ColorIndex = xlNone
Do While i
i am trying to create a excel macro to auto populate all the dates with reference to a start date and end date. The catch is that only working days are required in the range. My reference cells (start and end date) are in Sheet 1 while the destination cell range are in Sheet 2. The reason for creating a macro instead of a function is that the intervals between the start date and end date changes frequently (annual, semi-annual and quarterly) Best case scenario would be a button which I can just press after i input the dates to generate the range of dates in another sheet.
View 4 Replies View RelatedI have a form that loads and depending on the word selected in the drop down the following code loops through cells Q2:AC2 until it finds the word in one of those cells (the word will always be in one of the cells)
Code:
For Each c In Range("Q2:AC2").Cells
If c = period Then
c.Select
[Code]...
The active cell it finds will always change, i know I need something to code the active cell back but I don't know what it should be.
I am now trying to create a excel macro to auto populate all the dates with reference to a start date and end date. The catch is that only working days are required in the range. My reference cells (start and end date) are in Sheet 1 while the destination cell range are in Sheet 2. The reason for creating a macro instead of a function is that the intervals between the start date and end date changes frequently (annual, semi-annual and quarterly) Best case scenario would be a button which I can just press after i input the dates to generate the range of dates in another sheet.
View 1 Replies View RelatedI was looking for a final result as follows
21-Aug-09 + 1 = 24-Aug-09 (Day + next 1st working day)
21-Aug-09 + 3 = 26-Aug-09 (Day + next 3rd working day)
I created a spreadsheet with many CF's and save the sheet on our network, however, when my manager tries opening it the CF's do not work. they are there when I click on CF > Manage Rules, they just not working, neither is the Data Validation Drop Downs?
View 7 Replies View RelatedIn attached file I need doing sum where total working hours are not showing correct.
TotalingTime.xlsx
In A column the date something is received will be entered.
In B column there is a drop down list that has "insured" "Fee" "Aged Debt" "Other".
In C column I am trying to get another date to populate dependant on what is picked from column B, so if Insured is picked then 1 working day needs to be added to the date in column A and populate in column C. If any of the other 3 options are selected 5 working days needs to be added to the date in column A and populated in column C.
I have been using this formula: =IF(B2="","",IF(B2="Insured",A2+1,A2+5)) however this is not working days and I am stuck how to get to add working days
I have a dropdown answer column (J) to select an answer and in column (K) next to it that scores the answer. I'm trying to sum the score of (column K) in cell K7 but can't seem to get it to work.
View 3 Replies View RelatedI defined few name in manager but that are not working. I Defined names with multiple sheets with same Column.
See the attachment : Demo.xlsx