+ Reply to Thread
Results 1 to 2 of 2

How to shorten code

Hybrid View

  1. #1
    Registered User
    Join Date
    02-26-2007
    Posts
    5

    How to shorten code

    I am having a problem with trying to locate a way to shorten this code, could anyone please help.

    Sheet13.Range("A50").Value = FormMenu.txtName1.Value
    Sheet13.Range("A51").Value = FormMenu.txtName2.Value
    Sheet13.Range("A52").Value = FormMenu.txtName3.Value
    Sheet13.Range("A53").Value = FormMenu.txtName4.Value
    Sheet13.Range("A54").Value = FormMenu.txtName5.Value
    Sheet13.Range("A55").Value = FormMenu.txtName6.Value
    Sheet13.Range("A56").Value = FormMenu.txtName7.Value
    Sheet13.Range("A57").Value = FormMenu.txtName8.Value
    Sheet13.Range("A58").Value = FormMenu.txtName9.Value
    Sheet13.Range("A59").Value = FormMenu.txtName10.Value
    thank you
    Kindest regards

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by daymo
    I am having a problem with trying to locate a way to shorten this code, could anyone please help.

    Sheet13.Range("A50").Value = FormMenu.txtName1.Value
    Sheet13.Range("A51").Value = FormMenu.txtName2.Value
    Sheet13.Range("A52").Value = FormMenu.txtName3.Value
    Sheet13.Range("A53").Value = FormMenu.txtName4.Value
    Sheet13.Range("A54").Value = FormMenu.txtName5.Value
    Sheet13.Range("A55").Value = FormMenu.txtName6.Value
    Sheet13.Range("A56").Value = FormMenu.txtName7.Value
    Sheet13.Range("A57").Value = FormMenu.txtName8.Value
    Sheet13.Range("A58").Value = FormMenu.txtName9.Value
    Sheet13.Range("A59").Value = FormMenu.txtName10.Value
    thank you
    Kindest regards
    Hi,

    untested, but it's something like
    Dim myCtr as integer
    
    With Sheets("Sheet13")
    for myCtr = 1 to 10
        .Range("A" & 49+myCtr).Value = FormMenu.txtName & myCtr &  .Value
    next mtCtr
    end With
    hth
    ---
    Si fractum non sit, noli id reficere.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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