+ Reply to Thread
Results 1 to 9 of 9

range command issue?

  1. #1
    Registered User
    Join Date
    04-16-2012
    Location
    st pete, florida
    MS-Off Ver
    Excel 2007
    Posts
    6

    range command issue?

    I have a macro in excel that works.

    Please Login or Register  to view this content.
    …etc.

    If I open a csv and run this macro it selects the seen data and then later does stuff to it.

    *****

    when i try to turn this into a program i get an error.


    Please Login or Register  to view this content.
    would appreciate any ideas on what i'm doing wrong.

    thanks.

    jim

    Moderator's note: Please read our rules, #3 says code tags are required. I have added them for you because you are a new user. --6StringJazzer
    Last edited by 6StringJazzer; 12-23-2013 at 03:08 PM. Reason: code tags

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2411
    Posts
    26,715

    Re: range command issue?

    Quote Originally Posted by jim sturtz View Post
    when i try to turn this into a program
    What does this mean? Making it standalone VB code? If you are invoking this from outside Excel you may need to explicitly qualify the worksheet, rather than assuming a default to the active sheet. I'm not 100% sure of this but this is an easy fix to try:


    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    04-16-2012
    Location
    st pete, florida
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: range command issue?

    jeff, that worked swell. if i click into the sheet, the area i want is now selected.

    but im not referencing something correctly. when it gets to the next statement, i get an error, with i bet more to follow on the rest of my selection. statements.

    thanks.

    jim

    Please Login or Register  to view this content.
    Last edited by Leith Ross; 12-24-2013 at 04:33 PM. Reason: Added Code Tags

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2411
    Posts
    26,715

    Re: range command issue?

    You haven't answered my question about what you mean by "turning it into a program." Your code indicates you are executing Excel code from a different application. I think that means that you have to qualify Selection as oexcel.Selection (I think--I have done a lot of macros referencing Excel from Word and Project but avoid using Select and Selection in those cases). Also, "End With" needs a space.

    (Also, I see that another moderator added code tags for you in your second post. You really need to get with the rules or you could draw an infraction.)

  5. #5
    Registered User
    Join Date
    04-16-2012
    Location
    st pete, florida
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: range command issue?

    jeff,

    yes, i am running a standalone program. Sorry, I will reread the rules. I thought i put tags in. sorry. will let you know how that works.

    jim

  6. #6
    Registered User
    Join Date
    04-16-2012
    Location
    st pete, florida
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: range command issue?

    jeff,

    i ran into some other issues with values not working. found some sources to look thru and now things seem to be better and it runs. thanks.

    jim

    xltop=-4160
    xlleft=-4131
    xlltr=2

    With oExcel.Selection
    .RowHeight = 13
    .WrapText = .T.
    .Orientation = 0
    .IndentLevel = 0
    .Columns.AutoFit
    .ShrinkToFit = .F.
    .MergeCells = .F.
    .Font.Bold = .T.
    .AddIndent = .F.

    .HorizontalAlignment = xlLeft
    .VerticalAlignment = xlTop
    .ReadingOrder = xlLTR


    End with

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2411
    Posts
    26,715

    Re: range command issue?

    Sorry. Third time in the same thread. Have to.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  8. #8
    Registered User
    Join Date
    04-16-2012
    Location
    st pete, florida
    MS-Off Ver
    Excel 2007
    Posts
    6

    Smile Re: range command issue?

    Am i supposed to repost it then? this is actually the good code after your suggestions.

    Please Login or Register  to view this content.
    i have another question but i'll make a new post for it.

    thanks.

    jim

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2411
    Posts
    26,715

    Re: range command issue?

    You should edit the post rather than re-posting. At this point let's just move on.

    If the question you posted is now solved, please mark the thread as solved. Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

    Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro/Command button - cell reference issue?
    By mhblake in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-28-2012, 02:41 PM
  2. VBA to issue click command
    By randell.graybill in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-10-2010, 02:20 AM
  3. VBA Userform Issue - Command Button / msg Box
    By teeks in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-07-2010, 11:37 AM
  4. Is an IF command the best to resolve this issue?
    By dellf in forum Excel General
    Replies: 1
    Last Post: 09-25-2009, 11:34 AM
  5. LOOKUP Command Issue
    By VegasBurger in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-02-2006, 02:40 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1