I have a protected worksheet with a mixture of locked and unlocked cells, and I'd like to provide an option to allow the user to select a large range of mixed (locked and unlocked) cells and, in the unlocked cells only, pre-populate with a standard formula.
I've got most of it working, but what I need is the specific code that allows the user to specify the range of cells they want the macro to act on.
I have made a sheet where the user can insert/delete rows in a certain intervall of rows. The upper row is 17, that is I have named the cell "First" and then the last row "Last" and then I am using integers:
Dim intStartrow As Integer Dim intLastrow As Integer intStartrow = ActiveSheet.Range("First").Row + 1 intLastrow = ActiveSheet.Range("Last").Row - 1
So it is only possible to add/delete rows if the markerer is in between the above rows.
Now I would like to select the rows, from first to last. Since the rows are never the same, users add and delete rows all the time, I can not use
Can I somehow make a range selection using the Integers, somethimg like
With ActiveSheet Selection."intStartrow:intLastrow" End With
Private Sub CommandButton1_Click() Worksheets("Sheet1").Activate Range("A1").Select Selection.End(xlDown).Select ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate ActiveCell.PasteSpecial End Sub it errors to: SELECT METHOD OR RANGE CLASS FAILED
I download some data from a commercial real estate site about properties and their owners and process it in Excel. Out of 1,000 records, maybe 20 or so will have the data end up in the wrong fields. This is an artifact of the data source the commercial site uses.
Anyway, what I need to do is to get the data back in the right fields. So, I sort the data to pull together at the top of the sheet all the records with data where it's not supposed to be. So far, so good.
Now from one data download to another the number of records which end up in the sort will be different. And, here's the problem.
I try to record a macro mimicking my selection of the range of the data that needs to be moved. Fine, no problem. And, on the same dataset it works like a charm. But as soon as I put a different dataset into the spreadsheet with a different number of records that need to be corrected the macro fails.
Apparently, this is because the macro has been defined with a certain range of cells selected in the first data set and this same range is used for subsequent datasets with different numbers of errant records.
Basically, what I'm trying to record in a macro is the Shift/Control End and Shift/control arrow commands. But they don't record as such.
i have a spreadsheet that data is imported to from a different program. however the amount of rows of data will change from day to day. I need to be able to select this range of data before i run a macro on it.
I am trying to find a table of text, and copy it to another worksheet. I want to copy it as a range, not as rows or columns. Using Find, I can get to the 1st row of the table. Using Find again, I can get to the last row of the table.
What I don’t know how to do next is select the range.
For example; The table is in cells A10:F20. “Start” is in cell A10, and “End” is in cell A20.
Starting from cell A1, how do I find and select the range A10:F20.?
I will be doing this twice in the same macro, as there are 2 tables. Each of the 2 tables has the same “Start” and “End” text, as described above. The 2 tables will not always be located in the same location within the original WkSht.
How would a code look like to select a range with a column header on top. in the code you provided, it selected the entire W column. How would you select the range given that the W column was called Address?
I cant seem to get to work together in the same macro but that work great seperated. I need them to be in the same macro. The first just simply copy's text from one workbook to another:
Sub Test2() ActiveSheet. Range("a1").Copy _ Destination:=Workbooks("punchlist.xls"). Sheets("Sheet1").Cells(Rows.Count,1).End(xlup).Offset(1,0) End Sub
That worked ok but I needed to change it to the "active cell" instead of cell "a1". So then this line of code was made:
Dim userInputCell As Range
On Error Resume Next Set userInputCell = Application.InputBox("Use the mouse to select a cell on any sheet", type:=8) On Error Goto 0 If userInputCell Is Nothing Then MsgBox "Cancel pressed" Else Msgbox "You selected " & userInputCell.Address(,,,True) End If
The second code works just the way I want it but it doesnt copy over the text to the other workbook. I assume the 2 codes need to be together but I cant get it to work without errors. I also need the text to copy over without changing the borders on either workbook.
I have a client list in a table in my excel sheet. I currently enter the clients in a sheet that looks similar to a form. After the clients info is in this Form I have a button with a macro to copy the client info into a table on another sheet. This works perfectly.
Now I have another form that will retrieve the customers info in a click of a button in order to make changes to the client. Ei:I now have a second phone number and I want to update that client's info. What I want to do from here is take the info in Cell B2 (clients full Name), Do a vLookup in the "Saved Clients Table" in a Range within my table range. (Range: Saved Clients and the client's full name is in $A:$A and called "Clients Full Name" and once that name is found I need to select the cell in column C and the corresponding row.
This will allow me to copy the info in my form, Paste it in Transpose to the cell that is selected. (I already have that code)
Here are screenshots of what I am trying to accomplish. [URL] .......
I am trying to find a macro that can search a sheet for any cell that contains the text "Not on AOI" selects a range that contains that cell, 81 rows below, and 2000 columns to the right, then cuts the selection and pastes it 162 rows below the original cell where the text was found. What's hard is that the number of columns between the "Not on AOI" cells is variable.
I'm very new to excel macros and the parts I think I've put together are:
I have a command button on sheet MASTER. When the workbook is Activated I want it to check and see if in sheet COSTM, cell B3 there are the words "Project Number", if so then show command button (ClearPrevious), if not, don't show. Also, when the If statement is finished, then the workbook needs to end up showing the sheet MASTER. I have tried various codes and none work, or they are on perpetual loops. I know this has got to be simple, but cannot find an example to take from to solve the issue. Would appreciate any help offered. Below is code I have right now.
Private Sub Worksheet_Activate() If Sheets("COSTM").Select Range("B3").Select = "Project Name:" Then Me.ClearPrevious.Visible = True Else Me.ClearPrevious.Visible = False End If Sheets("MASTER").Select End Sub
My workbook holds a month template and sheets for each month. I work on modifications in the template ,but would then like to update all the monthly worksheets. I recorded a macro to show me how to start programming the vb sub, but get a runtime failure 'error 1004 Select method of range class failed' when trying to select the column to copy,
i want information on my "Intra-op tab" to automatically populate on my "Tissue" tab. In Column "A" of my intra-op tab i enter case id's, 1 per row, and i would enter a date received under column "D". On my "Tissue" tab, i also enter those case id's under column "A" but i would have multiple rows of the same number. I want that whenever i type a specific case id on my "Tissue" tab, it will automatically fill in the date in column "T", the date that coincides with the case id in column "D" of my "Intra-op Kit" tab.
I am trying to pause a macro on a protected sheet, select 2 adjacent cells (initially protected), utilize an existing drop down box to select a name from the list, copy the name from the list into the range of cells, then re-start the macro. I had no problem when there was just one name (see John Smith below). I tried to use the InputBox command but needed to actually type in the name.
if my excel file data in column a:h, and in column a is date data in every day. i try to know how to write vba code in the case of selection data by the date, that i want to select for any propose (copy or printing). eg. date data "dd/mm/yyyy" when i put it to input box
I'm trying to select a range of dates, contiguous from "AZ2" until the last entry using the following lines. The last cell in the column is selected instead of the entire range of dates from "AZ2" until the nth cell. I'm using Excel 2007. Below are the lines I'm using: