Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Simple VBA code not working on new laptop

I have the following code that is working fine on my PC, but I just got a new
laptop and it stops working on the line "ActiveSheet.Paste". I don't know
where to begin to look. Security is set to low. Thanks for your help.

Sub OpOutOfSequence()

Range("A1").Select
Range(Selection, Selection.End(x1ToRight)).Select
Range(Selection, Selection.End(x1down)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Simple VBA code not working on new laptop

Put Option Explicit at the top of that module, try to compile (Debug,
Compile VBA Project) and you will see what the trouble is.
Best to have this always at the top of all modules, so do:
Tools, Options, Editor, tick Require variable declaration.

RBS


"Alex" wrote in message
...
I have the following code that is working fine on my PC, but I just got a
new
laptop and it stops working on the line "ActiveSheet.Paste". I don't know
where to begin to look. Security is set to low. Thanks for your help.

Sub OpOutOfSequence()

Range("A1").Select
Range(Selection, Selection.End(x1ToRight)).Select
Range(Selection, Selection.End(x1down)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Simple VBA code not working on new laptop

You have in two places X1 instead of Xl (one instead of the letter l).

Sub OpOutOfSequence()

Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
End Sub


"Alex" wrote:

I have the following code that is working fine on my PC, but I just got a new
laptop and it stops working on the line "ActiveSheet.Paste". I don't know
where to begin to look. Security is set to low. Thanks for your help.

Sub OpOutOfSequence()

Range("A1").Select
Range(Selection, Selection.End(x1ToRight)).Select
Range(Selection, Selection.End(x1down)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,081
Default Simple VBA code not working on new laptop

On top of the other responses:

This line of code

Range("A1").currentregion.copy

can replace ALL of these lines

Range("A1").Select
Range(Selection, Selection.End(x1ToRight)).Select
Range(Selection, Selection.End(x1down)).Select
Selection.Copy


"Alex" wrote:

I have the following code that is working fine on my PC, but I just got a new
laptop and it stops working on the line "ActiveSheet.Paste". I don't know
where to begin to look. Security is set to low. Thanks for your help.

Sub OpOutOfSequence()

Range("A1").Select
Range(Selection, Selection.End(x1ToRight)).Select
Range(Selection, Selection.End(x1down)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Workbook event code won't work on laptop SoupNazi Excel Worksheet Functions 1 April 20th 07 11:38 PM
This should be so simple but it's not working, please help tahrah Excel Programming 4 January 16th 07 12:11 AM
simple formlas not working szelinko New Users to Excel 3 June 1st 06 03:31 PM
This should be simple but it's not working for me! hellokitty New Users to Excel 4 April 12th 05 01:26 AM
Save as not working for laptop to desktop Adra Excel Worksheet Functions 3 March 29th 05 10:55 PM


All times are GMT +1. The time now is 10:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"