Hi you all,
Normally I keep trying until I find what's wrong but this time I could use some help.
On column A, I simply do an A-Z sort that gives the expected result. So I recorded it as a macro.
In column G is a code that corresponds with column A. When the marcro is executed Column A is sorted but the corresponding value in G stays where it is.
Clicking the A-Z button works. But when that action is recorded as a macro I get the above quirck.
Since VBA is not my beef, I don't really know what wrong...
cheers,
edit; Doh, Monday morning; This should go into the excel section.
[MOD EDIT - moved]
Jeroen
Last edited by Jeroen1000; 09-21-2009 at 09:03 AM.
Can you post the code that is not working. Don't forget to use code tags.
hi Andy,
I think I got it. There was a formula on a column that changed my expected result. A bit stupid I didn't notice really.
Recorded macros generally need tidying up, but if you are satisfied with your solution please mar this thread solved.
How to mark a thread Solved
Go to the first post
Click edit
Click Go Advanced
Just below the word Title you will see a dropdown with the word No prefix.
Change to Solved
Click Save
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
Check out the free Excel Toolbar
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Code Tags: Make your code easier for us to read
I usually do my best cleaning them. I am curious how one would grade my code;
Code:Sub test() Dim Eurocode As String Dim Stickers As String Dim Verpakken As String Dim Eenheid As Integer ' Ask for Eurocode Eurocode = InputBox("Geef een Eurocode in en klik op OK", "Invoer vereist") annuleer: ' Provide the option to cancel If StrPtr(Eurocode) = 0 Then MsgBox "U heeft de invoer onderbroken. Er zijn geen gegevens toegevoegd", vbExclamation, "Waarschuwing" Exit Sub End If ' Keep asking for input if someone clicked OK but didn't fill anything in Do While Len(Eurocode) = 0 Eurocode = InputBox("U heeft niets ingetypt. Typ een Eurocode in of klik op annuleren ", "Invoer vereist") ' cancelling still has to be possible If StrPtr(Eurocode) = 0 Then GoTo annuleer Loop ' asking a few questions Stickers = MsgBox("Moeten er stickers gemaakt worden?", vbQuestion + vbYesNo, "Keuze vereist") If (Stickers = vbNo) Then Stickers = "NEE" Else Stickers = "JA" End If Verpakken = MsgBox("Moet er verpakt worden?", vbQuestion + vbYesNo, "Keuze vereist") If (Verpakken = vbNo) Then Verpakken = "NEE" Else Verpakken = "JA" End If ' fetch the last row. LastRow = Range("A" & Rows.Count).End(xlUp).Row ' doesn't work yet. Cells(1, 1).Value = Jeroen LastRow = Range("A" & Rows.Count).End(xlUp).Row ' sorting thingy Columns("A:A").Select ActiveWorkbook.Worksheets("Artikelen").Sort.SortFields.Clear ActiveWorkbook.Worksheets("Artikelen").Sort.SortFields.Add Key:=Range("A1"), _ SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("Artikelen").Sort .SetRange Range("A2:E" & LastRow) .Header = xlNo .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks