+ Reply to Thread
Results 1 to 4 of 4

VBA to run on just 1 sheet

  1. #1
    Forum Contributor
    Join Date
    02-09-2015
    Location
    malta
    MS-Off Ver
    Microsoft 365
    Posts
    383

    VBA to run on just 1 sheet

    Hi all,

    I know that this may sound really a beginners question, but I am quiet a newbie in VBA writing. I have the following code:

    Sub AutoFit()

    For i = 1 To Cells(Rows.Count, "D").End(xlUp).Row
    Cells(i, "D") = Chr(10) & Cells(i, "D").Text & Chr(10)
    Next i
    End Sub

    I would like it to work only for 1 particular worksheet and not for all the worksheets, say Sheet 1. How can I amend it?

    Thanks

    Keibri

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA to run on just 1 sheet

    Perhaps
    NOT TESTED

    Please Login or Register  to view this content.
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: VBA to run on just 1 sheet

    Add the word Worksheets("Sheet1") to all line before word Cells

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    02-09-2015
    Location
    malta
    MS-Off Ver
    Microsoft 365
    Posts
    383

    Re: VBA to run on just 1 sheet

    Thanks a lot guys that did the trick!!!

    Great 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. Lookup Value from Sheet 4 in Sheet 2, if found copy Sheet 2 Active Row to Sheet 5
    By lgosso23 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-11-2013, 02:51 PM
  2. [SOLVED] Match Value in Sheet 1 with Sheet 2, copy entire row from sheet 1 to new sheet
    By lzyshaman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-01-2013, 07:48 AM
  3. [SOLVED] find code# from sheet 1 on sheet 2, compare value on sheet 1 with value on sheet 2
    By BlakeLee in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-27-2013, 01:52 PM
  4. Replies: 11
    Last Post: 10-14-2012, 01:03 PM
  5. Replies: 2
    Last Post: 10-12-2010, 05:00 PM

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