Consulting

Results 1 to 5 of 5

Thread: Vba Code for data set passed with each press of a button.

  1. #1

    Vba Code for data set passed with each press of a button.

    Thank you in advance. Please view the attachment.Data Change with each press.docx

  2. #2
    VBAX Regular
    Joined
    Jul 2015
    Posts
    66
    Location
    Dear all

    Does anyone know how to sort numbers ascending with blank cells using VBA code without removing the blank cells?
    I will be very grateful is anyone can help me.

    Thanks
    Ali

  3. #3
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Simplemanny, that is easily done. Before doing it, would you want the count reset to 1 after the file is opened or leave the count from the last click?

    Had you attached a simple Excel file, it would have made helping you easier. You can always manually markup before and after needs and make extensive notes as you did in the docx file. It is best to first try and explain what you need before just saying see attachment. The attachment can be very detailed but simple is best when solving problems.

  4. #4
    VBAX Regular
    Joined
    Jul 2015
    Posts
    66
    Location
    Thanks Kenneth,
    Lets say, I want to sort the numbers which are in column(A) be sorted ascending without removing the blank cells as in the column (D) as shown in the attached file.
    Regards.
    Ali
    Attached Files Attached Files

  5. #5
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Simplemanny, in the "profile inserts" range XFD1, put a value of 0.

    In a Module, paste this code and assign the macro to your form control button.
    Sub ClickCopy()  
      Dim xfd1 As Range, c1 As Range, c2 As Range
      With Worksheets("profile inserts")
        Set xfd1 = .Range("XFD1")
        Set c1 = .Range("C3")
        Set c2 = .Range("C4:C78")
        
        If xfd1.Value2 = 8 Then xfd1.Value2 = 0
        
        c1.Offset(, xfd1.Value2).Copy Worksheets("data input").Range("C13")
        c2.Offset(, xfd1.Value2).Copy Worksheets("data input").Range("C16:C90")
        
        xfd1.Value2 = xfd1.Value2 + 1
      End With
    End Sub

Posting Permissions

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