Pasting into an active cell

I have some VBA code (see below) where I am copying a fixed selection from 
one workbook (which the user has selected), into the next empty row in a 
different workbook (where the macro is located).


Sheets("National").Select
Range("A6:X21").Select
Selection.Copy

Windows("Diagnostics 2010-2011.xls").Activate
Sheets("C-National").Select
Selection.paste

However, I get a run time error (438) on the paste command when I try to run 
it.

Any suggestions, as I am new to VBA
0
Utf
3/1/2010 11:39:01 AM
excel.programming 6508 articles. 2 followers. Follow

3 Replies
1485 Views

Similar Articles

[PageSpeed] 24

Try the below which will copy the range from the Activeworkbook Sheet 
National to openworkbook Diagnostics Sheet c-national...

Sub Macro()
Dim wb As Workbook

Set wb = Workbooks("Diagnostics 2010-2011.xls")
Sheets("National").Range("A6:X21").Copy _
wb.Sheets("C-National").Range("A1")
End Sub



-- 
Jacob


"BoRed79" wrote:

> I have some VBA code (see below) where I am copying a fixed selection from 
> one workbook (which the user has selected), into the next empty row in a 
> different workbook (where the macro is located).
> 
> 
> Sheets("National").Select
> Range("A6:X21").Select
> Selection.Copy
> 
> Windows("Diagnostics 2010-2011.xls").Activate
> Sheets("C-National").Select
> Selection.paste
> 
> However, I get a run time error (438) on the paste command when I try to run 
> it.
> 
> Any suggestions, as I am new to VBA
0
Utf
3/1/2010 11:56:01 AM
To Activecell

Sub Macro()
Dim wb As Workbook

Set wb = Workbooks("Diagnostics 2010-2011.xls")
Sheets("National").Range("A6:X21").Copy _
wb.Sheets("C-National").ActiveCell
End Sub


-- 
Jacob


"BoRed79" wrote:

> I have some VBA code (see below) where I am copying a fixed selection from 
> one workbook (which the user has selected), into the next empty row in a 
> different workbook (where the macro is located).
> 
> 
> Sheets("National").Select
> Range("A6:X21").Select
> Selection.Copy
> 
> Windows("Diagnostics 2010-2011.xls").Activate
> Sheets("C-National").Select
> Selection.paste
> 
> However, I get a run time error (438) on the paste command when I try to run 
> it.
> 
> Any suggestions, as I am new to VBA
0
Utf
3/1/2010 12:01:01 PM
Hi,

Try this

Sheets("National").Range("A6:X21").Copy _
    Destination:=Workbooks("Diagnostics 
2010-2011.xlsx").Sheets("C-National").Range("A1")
-- 
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that 
introduces the fewest assumptions while still sufficiently answering the 
question.


"BoRed79" wrote:

> I have some VBA code (see below) where I am copying a fixed selection from 
> one workbook (which the user has selected), into the next empty row in a 
> different workbook (where the macro is located).
> 
> 
> Sheets("National").Select
> Range("A6:X21").Select
> Selection.Copy
> 
> Windows("Diagnostics 2010-2011.xls").Activate
> Sheets("C-National").Select
> Selection.paste
> 
> However, I get a run time error (438) on the paste command when I try to run 
> it.
> 
> Any suggestions, as I am new to VBA
0
Utf
3/1/2010 12:06:01 PM
Reply:

Similar Artilces:

The active schema does not support the element 'xml'
I am trying to insert an xml data island into a htm file that I am using for a help file. When I insert the lines of xml, the <xml> tag is underlined in red in VS2003 and the message says "The active schema does not support the element 'xml'. the html is as follows <HTML xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <HEAD> <meta name="vs_targetSchema" content="HTML 4.0"> <TITLE>Setting Options</TITLE> <xml><MSHelp:Keyword Index="K" Term="Random" /> <MSHelp:Keyword In...

recognize the cell
Hi! I have a workbook named Ever and a worksheet called Ton, like this: Row/Column A B C D E F 1 Me 1 Abc 1.2 Etc Etc 2 You 2 Def 1.4 3 2Me 3 Klm 1.3 4 2You 2 Opp 1.3 1. I’m wondering if it’s possible to write a code in VB that recognize the cell the user are pointing/clicking at (with the mouse) no matter were in the worksheet the user is pointing and mark the hole row? 2. If 1. is possible can a input...

Questions re Activities
Is there a way to add the Date Created column to the Activity display? At present I may have a Case or a Contact with lots of activities but they don't appear in chronological order and I have to open each one up and go to File/Properties menu to find the date - would be much easier to do a sort by date. And..does anyone know what the Activity Category and Sub-Category fields are for? There is nothing in the online help and these fields are not listed via the Advanced Find area and so are not searchable. Thanks in advance. Sue ...

Text is added as attachment after copy and paste
Hi I am using outlook 2000 and every time I want to copy and paste text from somewhere else (e.g. browser), it adds the content as an html-page-attachment to my new mail. I just want to have it added as simple text in the mail-body regards R. Save the text in notepad or something and then Insert the file - but check the button so it inserts it as text, not just as an attachment ;-) r@gnar.de wrote: > Hi > > I am using outlook 2000 and every time I want to copy and paste text > from somewhere else (e.g. browser), it adds the content as an > html-page-attachment to my new ...

set a default value for a cell ?
I want to set a default value to a cell or set of cells which might be edited by the user? I have a column which is used by a person to enter values. But A default value should appear. Could you please help me? see help on data validation or debra degliesh's page http://www.contextures.com/tiptech.html "Jeethu" <Jeethu@discussions.microsoft.com> wrote in message news:5A34C3B6-EF14-40AB-9CC6-E590AED4B6D8@microsoft.com... >I want to set a default value to a cell or set of cells which might be >edited > by the user? > > I have a column which is used by...

No return on basic search of activities, CRM 4.0
If I go into activities and view all of my activities I get the full list of phone calls and emails. However if I try to search for an activity that I've carried out with a contact i.e. John Smith, The Company. I get no results returned if I search on either term, even though an activity on this account is in the list. If I go to Advanced Find, I can search for John Smith and/or The Company and the contact is then returned in the search. Why is the basic search not working? (I'm using the web client) Thanks in advance! Hi, Have you configured your required columns to be ...

View Excel Cells in Color
When a fill with a color an excel cell, the screen didnt show me the color ive apply to cell. I have to click the preliminary presentation icon to see the color i ve applyed. Is this an excell error? Why should i do to fix it? The first thing I'd suggest is posting your question in the Excel newsgroup instead of Publisher. -- JoAnn Paules MVP Microsoft [Publisher] "andres torres via OfficeKB.com" <forum@nospam.OfficeKB.com> wrote in message news:c282191dd452428491c39a28c93cb703@OfficeKB.com... > When a fill with a color an excel cell, the screen didnt show me th...

Add Custom Activity Type
I have been asked to add a custom actiivity type to the activities entity called Site Visits. Can I get some direction as to how to do this? Afraid, you can't add custom activity types. You can create the entity, but it will behave like any other and does not integrate into the activity views and activity dialogs. -- Michael H�hne, Microsoft Dynamics CRM MVP Web: http://www.stunnware.com/crm2 Feed: http://www.stunnware.com/crm2/atom.aspx Custom Lookup Dialog: http://www.stunnware.com/crm2/?area=customLookup ---------------------------------------------------------- "Swamy&qu...

Tally chart cells exist in Excel!??
Hello I was wondering if for example there exists a way in which yo have a cell which u put a line like &#9553; to represent "1" so fo example if you have 5 of those lines in a cell, i want the cell besid to display the number "5". Is this possible, if so can anyone explain me how to do it Thanks for your time From John Woo -- Neo ----------------------------------------------------------------------- Neo1's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=3032 View this thread: http://www.excelforum.com/showthread.php?threadid=50618 H...

VLookUp and DropDown List in the same cell
Hi everyone, I know that this is possible but I'm not sure how to accomplish this. In column E, I have a list of zip code. In column I, I have the "Priority" category. Priority will be based on the zip code in column E. This will be accomplished by VLookUp formula, where I will have a separate sheet store all the zip codes and the priorities (ie. Priority #1, Priority #2 and so on). The challenge part is that column I "Priority" column needs to be able to use as a Drop Down List as well, in case that the VLookUp formula needs to be overridden for so...

formatting cells to show time format
Hi I wonder if you can help me with the following. I use Office 97 Professional, and Excel 97 to do the following. I have created a spreadsheet that will be used to calculate times & results for Car Rallies. I have sorted out the formatting of the cells so they show hours, minutes, seconds, and down to thousands of a second, using this time format hh:mm:ss.000. I have done the formulas to work out the elapsed times and then total times, by taking the finish time from the start time etc, then adding elapsed times together to get total times. The thing I am trying to sort out is wh...

Combine cell totals from 5 sheets into summary in Excel
Hi Milor, =SUM(Sheet1:Sheet5!A1) --- Regards, Norman "milor" <milor@discussions.microsoft.com> wrote in message news:440449BE-3F82-40E1-ADFB-DD2C261045EC@microsoft.com... > ...

Role-based authentication from active directory
Hello, I want certain pages of my website visible only to a particular role in the network (Active Directory) How do I check for authentication from active directory (role-based) Eg-- I want the only managers in the active directory to access a particular page. Please provide me some code by which I can achieve this. Thanks On Feb 15, 8:31=A0pm, "Biranchi Narayan Panda" <biranchi_pa...@hotmail.com> wrote: > Hello, > > I want certain pages of my website visible only to a particular role in t= he > network (Active Directory) > > H...

linking colored cell
I have a worksheet(A) with data linked to a second one(B); when I forma any (A) cell with a selected color, I would like to transmit the ne cell color to the linked one in (B); suggestions will be welcome -- Gerbati ----------------------------------------------------------------------- Gerbatin's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1523 View this thread: http://www.excelforum.com/showthread.php?threadid=26867 Cannot be done unless Condtional Formatting is used on both cells to produce the color. OR VBA code. Gord Dibben Excel MVP On Tue, 12 Oct 2...

sum cells
I am trying to total employee schedule so some cell have D/O day off, R/O requested off, so when I try to total all associates by the day I get #VALUE! in cell and total cell. Is there a way to total only numbers and ignore #VALUE! Try this: =SUMIF(A1:A10,"<>#VALUE!") Why not fix the formula that causes the error in the first place? What is the formula that does this: >when I try to total all associates by the day I get #VALUE! Biff "SteveD" <SteveD@discussions.microsoft.com> wrote in message news:7D8BF85A-F76E-4F35-95AC-50B77B128304@microsoft.com....

Typing in multiple row in a single cell
Is there a way to divide a cell in multiple rows? I am not talking about the insert the Text Box or table. The cell it self should be able to take text in multiple rows. for example to type "My address My Street My City" Three rows in one cell Khusro Hi Format>Cells>Alignment>Wrap text Then press Alt+Enter at each point you want to create a new row. As an aside, entering data in this format is not the most useful way to store data. Very often, you want to pull out the City separate form other things, for example. It would be better to store your data in separate ce...

Edit Cell Contents
I want to hit F2 to edit a cells contents and keep what was on the clipboard. brauer.greg@gmail.com wrote: > I want to hit F2 to edit a cells contents and keep what was on the > clipboard. Good for you! You should. No dave, when you copy something and then hit F2 to enter a cell and paste it it is not there. I guess the potential workaround is to hit ctrl + C twice it brings up the contents of the clipboard and all is not lost, however this still makes me reach for the mouse which I try to avoid doing. So dave do you have anyother workaround other than Ctrl + c twice? davegb wr...

Drag Formula cell to decrement the cells #2
Ken, I do thank you for your prompt assistance. The solution you gave me works fine but with limited No. of cell (sorting problem) is there a way to do it in an unlimited No. of cells (e.g. 50 or 6 cells - BI till DP to be the mirror of A till BH ) Thanks Agai -- Asher Zu ----------------------------------------------------------------------- Asher Zur's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1610 View this thread: http://www.excelforum.com/showthread.php?threadid=27554 Sure, just follow instructions as before and in BI1 put =A1 and copy across to DP...

Sheet name as cell value
Is there a formula, or "dynamic" method of taking the sheet name an putting it as a value in the same sheet. If the sheet name changes, the cell then updates with the new name. ? -- Jo ----------------------------------------------------------------------- Jon's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=317 View this thread: http://www.excelforum.com/showthread.php?threadid=27051 Hi =MID(CELL("filename",$A$1),FIND("]",CELL("filename",$A$1))+1,36) Arvi Laanemets "Jon" <Jon.1eds5z@excelforum-nospam....

Sort Cells/Columns
I have three lists of items (numbering about 150) on a single sheet using columns A, D & G. I need to sort these in alphabetical order continuous across all three columns. All I get at the moment is each column individually sorted, which is no good to me. Can anyone help? TIA Ed Give us an example with 3 rows of 3 columns before and after the sort. best wishes -- Bernard V Liengme www.stfx.ca/people/bliengme remove caps from email "Ed O'Brien" <edward.j.obrien@deletebtinternet.com> wrote in message news:exodmwP0GHA.3464@TK2MSFTNGP03.phx.gbl... >I have t...

Reference cell error
Hi When I use the following formula, I get #REF error. How can I fix it? Thank you =SUM('Daily Sworn Status'!M8) probably a misspelling of the sheet name da;722686 Wrote: > Hi > When I use the following formula, I get #REF error. > How can I fix it? > Thank you > > =SUM('Daily Sworn Status'!M8) -- p45cal *p45cal* ------------------------------------------------------------------------ p45cal's Profile: http://www.thecodecage.com/forumz/member.php?u=558 View this thread: http://www.thecodecage.com/forumz/showthread.ph...

referencing a cell determined by name in another cell
How do I reference a cell within a formula based on the contents of another cell? For example if one cell contained a reference/address for a column array, how could I refer to this cell (and hence the column array) within the vlookup function instead of having to put in the actual table array. In other words an external way of changing the table array rather than going into the formula. VLOOKUP(lookup_value,table_array,col_index_num,range_lookup) Hi use INDIRECT for this -- Regards Frank Kabel Frankfurt, Germany "ricardo wants answers" <ricardo wants answers@discussion...

cant activate user
I upgraded an CRM 1.2 installation to CRM 3.0 - with no big problems. But now I cannot activate users or change restricted access mode setting. When I try to do this and hit save and exit an error page appears. Anyone any idea where I could look at to solve this problem? ...

combining cell entries
I remember having read a simple formula for combining the entries in cells (be it text or numbers), so that the result shows in another cell. Example: cell A1 has Lotus and cell A2 has 123 The formula placed in let us say cell C5 delivers me : Lotus123 It was very simple but i cannot find it anywhere Please help!! One way: Use the concatenation operator: =A1 & A2 another: use the Concatenation Function: =CONCATENATE(A1,A2) In article <56tagv0nkvfjelpt2ka2s29aum4r2a434r@4ax.com>, rjz@haaghuishof.nl wrote: > I remember having read a simple formula for combining ...

How do I show info only in cells used
IF(X15="paid","",IF((TODAY()-C10)<14, "Overdue", "PAID")) I have used the formula above to show if an invoice is out of date/unpaid, however I have dragged the formula down into cells that are currently empty and they are showing Overdue... How do I make these cells appear blank until the cells have inf. in them. I am not clear on your rules here. Clearly, If X15 says paid, then there is nothing to output, but is C10 a due date? If so you will get Overdue when the date is in the future, which seems perverse. This seems a better fit to me =IF(X1...