Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I have some problems using a single button to copy cells from one sheet to
another - I get a runtime error 1004: "Select method of Range class failed". The way I have it set up right now is that I have a button on sheet1 that takes a String from sheet1 as input, copies Rows2:18 from sheet5, selects the last row with content on sheet1, and pastes the copied material, then selects Rows20:36 from sheet 5, selects the last row on sheet2, and pastes the new copied cells. I've set it up as follows: Sub Click(): Gets the String input from a cell on sheet1, and then calls CopyToSheet1(Stringinput) and CopyToSheet2(Stringinput) In CopyToSheet1(Stringinput) I have it do the following Find the last row of sheet1: Dim LastRow As Integer LastRow = Worksheets("Sheet 1").Cells(ActiveSheet.Rows.Count, "B").End(xlUp).Row + 2 Then I print the StringInput in a cell on sheet5, copy rows(2:18) from sheet5, and finally paste my copied material: Worksheets("Sheet 5").Rows("2:18").Copy Worksheets("Sheet 1").Cells(LastRow, 1).Select ActiveSheet.Paste This works great. It manages to find the right cells on sheet5, and it manages to find the last row on sheet1, and it pastes perfectly. I would like to get rid of the extra step, and just have paste it directly rather than selecting first and pasting to activesheet, but as far as I can tell it's not possible to simply replace Copy with Paste ("object doesn't support this property or method"). Anyway, that works fine. For copytosheet2, however, I get "Select method of Range class failed" when it's trying to select the last row on sheet2. The debug shows me that it's defined the lastrow properly (in the test case it's defined as "29" on sheet2, whereas it's "23" on sheet1), but it simply can't select it. Is this because the button is on sheet1 and the selection I want is on sheet2? That doesn't seem to stop the .copy command which works fine; can i get .paste to do this for me? I tried to be as detailed as possible, and hopefully it was possible to follow my description and you know how to help me. Thanks! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
I wan to select a button | Excel Discussion (Misc queries) | |||
autofill button is not appearing when I select cells in Excel 2007 | Excel Worksheet Functions | |||
Creating/Naming New Worksheets Based on Select Cells in Master Worksheet | Excel Worksheet Functions | |||
Excel 2003 is missing toolbar button select visible cells | Excel Worksheet Functions | |||
select specific cells and consolidate same over many worksheets | New Users to Excel |