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 searched and found many examples of code that will lock cells once data has been entered. But for some reason, I cannot get it to work in my workbook. The weird thing is, I have successfully got them to work on blank workbooks. I unlock a range I want people to be able to edit, I protect the workbook, I enter the code, and it works. But I do the same thing on my workbook, nothing locks.
I've tried locking all the cells on a sheet, and only unlocking a small range, as in the examples (A1:A10), and I cant get it to work. I've tried not pre-protecting the sheet, I've tried 4 or 5 different examples of code. If it wasn't for the fact I've gotten it to work on blank workbooks, I'd think VBA was disabled or something. I can't post a copy of my workbook for you all to look at because its on a stand-alone computer at work (and the USB is disabled for info-sec).
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
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 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 have shapes in 3 different rnages of cells on a cell worksheet: R1 = $D$5:$D & lngRows (row=32) R2 = $G$5:$G & lngRows (row = 51) R3 = $M$5:$M & lngRows (row = 50)
I need to set the properties of the shapes in each range differently The shapes in R1 are Left + 46 But the shapes in the other 2 ranges need to be just left My problem is in this bit
Code:
'Set properties for each shape in ShapeRange For Each sh In ws.Shapes
I need to be able to set properties for each range separately instead of the entire sheet. Full code below (only Range $D at the moment - works)
Code:
Option Explicit Sub AddShape3() 'Purpose: Add small rectangles to database table/fields for ' brainstorming and documenting relationships and queries ' 'Resources:
Sheet 1 - I have columns filled with dates (weekdays only) For example 28-May, 29-May, 30-May up to 28-Nov. Above 10 rows below each date columns and each cell has some values.
Sheet 2 - I have Start date defined in B1 Cell, and End date defined in B2 Cell
I need defining the formula to sum all the cell values fall between the date range defined in Sheet 2 B1 and B2.
For Example if B1=28-May B2=30-May, I want the sum of all the numbers come under the range of 28-May to 30-May, with this above example, it should be 19.5.
I'm new to Excel 2007... whilst I'm managing to find most things I'm used to using in 2003, I have an issue in one workbook that I can't figure out.
When I click in some single cells (not all), that cell and several below it automatically highlight as a range... left-clicking initially highlights the cell, but as you release the mouse button, the others below it also highlight.
I have a range selected (A4:C15).I would like to deselect the range and make A4 the active cell. Is this possible without a macro?
With a macro, one could use: Application.Goto Selection.Cells(1)
I generally select a large number of cells and would like to go back to the start cell in the range. I could do it by pressing the left and right arrow keys but is there a shortcut that will allow me to do the same?
I want to count the number of cells in a range that have text in them (any text at all) but not count them if they have numbers in them or are blank. How would this formula be written?
Column A & B has a list of Supplier Part numbers and Buyer Part numbers as below.
Supplier P/N Buyer P/N
HGFYE/12 111111
HYEYDH/14 222222
[Code] ..........
Cell D2 is an open cell that any data can be entered into as a search term. What I am trying to do is search for a Supplier P/N that have the characters "H", "G" or "E" in it, so entering "HGE" into cell D2 would display the results into columns F & G as below.
Supplier P/N Buyer P/N
HGFYE/12 111111
HDGTEY/56 333333
I can easily do a formula for 1 character or a string of characters.
To complicate it further, if the search term has in this example has "YFF", I would like the same formula/code to workout that the result in F & G should show this time
All my macros have suddenly started crashing Excel 2007 when I try to run any one of them. I can record a new macro but even that newly recorded macro will crash Excel.
Service Pack 1 was downloaded and installed by Windows Update two days ago and I had successfully run macros after SP1 was installed.
Today, it's a no go and I'm at a loss as to what may have caused this problem. I have not installed any software lately, other than the Windows updates on patch Tuesday.
This is on a Vista Home Premium machine.
When I try to run a macro, Excel crashes with this info:
I have a workbook that uses a index page that I created. It has lots of hyperlinks on it to route them to other sheets in the workbook. Each worksheet has a hyperlink to go back to the index page, and one to open an email. I have a user with 2010 now that is getting an error when clicking on the hyperlink. Error Message: "This Operation Has Been Canceled Due To Restrictions on the Computer. Contact Your Administrator."
application.FileSearch.NewSearch application.FileSearch.LookIn = Workbooks(ActiveWorkbook.Name).Path application.FileSearch.FileType = msoFileTypeAllFiles application.FileSearch.SearchSubFolders = True application.FileSearch.Filename = "Zone Selling*.xls" application.FileSearch.MatchTextExactly = True application.FileSearch.Execute filecount = application.FileSearch.FoundFiles.Count For i = 1 To filecount Worksheets("Run").Cells(i, 1) = application.FileSearch.FoundFiles(i) Next i For i = 1 To filecount......................
But it won't list my files which is how the macro was running, it was returning a list of the files in the folder and then running them based on the path returned
I am trying to migrate a model that I built in Excel 2002 to Excel 2007. The model has an advanced filter in it to get unique values. However in 2002 the filter worked correctly but in 2007 it produces nothing. The code excerpt is below :-
I am trying to use the NETWORKDAYS function in excel to calculate the working days for my company. the problem is I m located in UAE and here Saturdays and Fridays are official days off for my company. Now the problem is that the excel have this built in function that Sunday and Saturdays are weekend days. I want to customize the function for my local days off for my company.
I wrote a macro to list all the excel files from a directory and its sub-directories to an excel sheet. It is working in excel 2003 but shows error (object does not support this action) in 2007. Actually I have copied almost this entire macro from excel 2007 help only. Can somebody modify this to use in both the versions of excel?
I have used the following code behind a projects Command button for some time, and works well in Excel 2002/2003. It's used to look for and insert a Picture file, located on the users PC, select cell C2, re-size it to fit inside a bordered cell area and then nudge it over, off the border line.
Sub Load_Image() Dim oPict, PictObj Dim sImgFileFormat As String 'Open file GetPict: oPict = Application.GetOpenFilename("All Pictures (*.tif; *.bmp; *.jpg; *.gif; *.jpeg; *.png; *.cpt; *.tiff),*.tif; *.bmp; *.jpg; *.gif; *.jpeg; *.png; *.cpt; *.tiff") If oPict = False Then End Range("C2").Select Set PictObj = ActiveSheet.Pictures.Insert(oPict) With PictObj .ShapeRange.LockAspectRatio = msoFalse .ShapeRange.Width = 712# .ShapeRange.Height = 510# End With PictObj.Select With PictObj Selection.ShapeRange.IncrementLeft 1# Selection.ShapeRange.IncrementTop 1# End With Range("A1").Select
End Sub
Unfortunately, Excel 2007 doesn't seem to identify the Cell reference "C2". It modifies the Picture size OK but does not position the picture in the correct position. I've tried re-recording it but 2007 misses most of actions.??? Despite my efforts looking on other forums, I don't seem to find a code that works on both version of Excel.
Arrow keys do not move from one cell to the next. They advance the page or panel view. No spreadsheet works correctly, (new or existing) and scroll lock is not set.
Hello all. I have the following code that works for Outlook 2003 but does not work for Outlook 2007. Does anyone know what changes need to be made so this macro will work in both Outlook versions?
I recently had a virus on my computer and had to replace it. I had a ton of macros saved in my Personal.xlsb workbook, so I exported those modules and have now imported them to the new Personal.xlsb file. Now for some reason those macros no longer work in other files. Most of them are basic, like I have a macro to paste values or paste formats, etc. but I have some others that are very complex. The macros work fine as long as I am in Personal.xlsb, but if I try to use them in another open workbook I get the "all macros may be disabled or the macro may not be available in this workbook" message. I am using Excel 07 and have verified that macros are enabled.
I am trying to use a simple formula: COUNTIF($CT$2:$CT:$430749,CT2)
I am trying to fill this down all the rows (430,749 rows). The formula behaves as its supposed to up to around row 650. After this point, all resulting values are all the same, which happens to be the same value that was returned from the original formula in C2. However, this is not correct. It's like the formula just stops working after row ~650. I tried F9 without success.
I'm trying to validate a cell in Excel 2007 that should contain only two letters.
Formula: Code: =IF(AND(LEN(A1)=2,ISTEXT(A1)),TRUE,FALSE) When the value of A1 is JK, the result is TRUE When the value of A1 is 12, the result is FALSE
When the value of A1 is 3K, the result is TRUE When the value of A1 is K3, the result is TRUE
When the value of A1 is 123, the result is FALSE When the value of A1 is JKL, the result is FALSE
When the value of A1 is 3, the result is FALSE When the value of A1 is K, the result is FALSE
The LEN function works as expected, but the ISTEXT function does not, whenever the cell contains a number and a letter. I've tested the LEN and ISTEXT functions separately, and get the same results.
Dim strLoan As String Dim longCat As Long Dim rHere As Range Range("A1").Select [Code] .....
I can see the cursor move to all the desired cells when this macro executes; it just isn't dropping any data where it should be. I have been working at this stage for the last five hours with no success. I don't know whether my copy-paste methodology is broken or if it is my selection criteria
formula using if's and vlookup's to populate a calendar with x's for day a person is gone. however the last couple of people that are gone are not being marked on the calendar even though i use the exact same formula (except for cell numbers and such) for previous, working entries. Here is my formula