PDA

View Full Version : Vba Code for data set passed with each press of a button.



simplemanny
07-30-2015, 08:31 AM
Thank you in advance. Please view the attachment.14040

alihadi
08-02-2015, 06:51 AM
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

Kenneth Hobs
08-03-2015, 06:36 AM
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.

alihadi
08-03-2015, 07:18 AM
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

Kenneth Hobs
08-03-2015, 08:13 AM
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