+ Reply to Thread
Results 1 to 12 of 12

Modification to Macro for row to start

  1. #1
    Forum Contributor
    Join Date
    11-11-2012
    Location
    Muscat, Oman
    MS-Off Ver
    Office 365
    Posts
    521

    Modification to Macro for row to start

    Dear Experts,
    A member helped me with a code that cuts all the columns after a column and pastes it under the column. So far it works very well then it inserts a column and populates it with Data1, Data2 etc.
    My problem is Instead of Data1 & Data2 I would like to see text in row 2 of that column (Which is the real header and row one is blank)
    Not too sure if I have expressed correctly or no….
    Please Login or Register  to view this content.
    Last edited by VKS; 01-06-2013 at 02:15 PM.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Modification to Macro for row to start

    Maybe this is what your asking...

    This
    Please Login or Register  to view this content.
    Sets the first row where the pasting will begin. If you want it to start or row 2 instead of 3 then just change to 2.

    Another great way for you to see what is happening, open the VBE and use the F8 key to step through the macro so you can see what is happening and what the variable are doing.
    HTH
    Regards, Jeff

  3. #3
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Modification to Macro for row to start

    Just a point of information. The variables are incorrectly declared, though this won't cause an issue with the code because VBA will interpret the variable type.

    In the code below, i, j, k and jmax appear to be type as Long variable. In reality, only imax is explicitly declared as long.
    Variable i, j, k, and jmax are seen as Variant types, not Long. Same goes for fn1.

    Please Login or Register  to view this content.
    Properly declared:
    Please Login or Register  to view this content.
    Read here: Declaring Variables
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  4. #4
    Forum Contributor
    Join Date
    11-11-2012
    Location
    Muscat, Oman
    MS-Off Ver
    Office 365
    Posts
    521

    Re: Modification to Macro for row to start

    Thanks Jeff, I will try F8 option.
    Pasting is not an issue here it cuts and pastes fine but my problem is it should pick up row two of the column in the newly inserted column A instead of using Data1, Data2, Data3 etc
    Thanks/VKS

  5. #5
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Modification to Macro for row to start

    I'm sorry, not so much following. Can you attach a small representative sample with a before and after...

  6. #6
    Forum Contributor
    Join Date
    11-11-2012
    Location
    Muscat, Oman
    MS-Off Ver
    Office 365
    Posts
    521

    Re: Modification to Macro for row to start

    I am sorry Jeff, This is the original thread i had started where i managed to get some help
    http://www.excelforum.com/excel-prog...html?p=3066722
    Please do let me know if you still want me to create a dummy file since i have my limitations in sharing the original data.
    Thanks/VKS

  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Modification to Macro for row to start

    Hi VKS,

    Instead of me trying to decipher what is going on here, a sample file with your exact requirements and a before and after will alleviate and guess work.

  8. #8
    Forum Contributor
    Join Date
    11-11-2012
    Location
    Muscat, Oman
    MS-Off Ver
    Office 365
    Posts
    521

    Re: Modification to Macro for row to start

    Hello Jeff,First of all my apologies for pasting the link. I hope the attached file explains my problem/requirement.
    Best Regards/VKS
    Attached Files Attached Files

  9. #9
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Modification to Macro for row to start

    See if this will work for you. Instead of putting in C in Range A1 use a numeric value for the column. So for column C use 3.

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  10. #10
    Forum Contributor
    Join Date
    11-11-2012
    Location
    Muscat, Oman
    MS-Off Ver
    Office 365
    Posts
    521

    Re: Modification to Macro for row to start

    Dear Mike, Thanks for your help... attached please find the error i get using your code.
    Best Regards/VKS
    Attached Files Attached Files

  11. #11
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Modification to Macro for row to start

    you need to change Before Running the Code to the sheet name that your working with.

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    11-11-2012
    Location
    Muscat, Oman
    MS-Off Ver
    Office 365
    Posts
    521

    Re: Modification to Macro for row to start

    Hello Mike, You already have my One Star wish i could give you Five for this one.....
    Thanks again Mike. THANKS A LOT

+ 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