PDA

View Full Version : Solved: Another cross platform problem



prm
10-21-2005, 05:17 AM
Hi,

I have another issue with cross platforming from PC to Mac.

I'm not receiving any errors, but when the form NEXTPRACA1 is loaded it is ignoring the data that should be shown from the sheet "PRACA" in the a3:s3 columns. It just keeps repeating the same data no matter what data is selected. On the PC the range a3:s3 is shown on the form per the data selected. I'm back to the what coding works on PC doesn't necessarily work on a Mac. The form shows perfectly on the Mac but not the data.

Sub TextBox4_Click()
Range("A1:t99").AdvancedFilter _
Action:=xlFilterCopy, _
CriteriaRange:=Range("u1:u2"), _
CopyToRange:=Range("v1:ao1"), Unique:=False
Range("w2:ao2").Copy
Sheets("PRACA").Select
Range("A3:s3").Select
Selection.PasteSpecial
Sheets("Select").Select
Range("a2:a99").ClearContents
Range("A2").Select
Application.ScreenUpdating = True
NEXTPRACA1.Show
End Sub


Any suggestions would be appreciated.

Thank you,
prm

JonPeltier
10-23-2005, 06:46 AM
I don't know how you're populating the userform. You should have code explicitly loading data into controls, either before showing it in the calling procedure, or in a UserForm_Activate procedure in the form's code module. (I've found, and others have concurred, that linking userform controls to worksheet ranges is less than ideal.)

Also note, that if you populate the form when it is first instantiated, then merely hide and reshow the form, it is still populated with the original values, unless you've explicitly reloaded new values.

prm
10-24-2005, 05:06 AM
I am loading the data from the spreadsheet by using =PRACA!E3 (cell location of data) into the form data fields, I guess not the ideal way.
I will try a UserForm_Activate procedure in the form's code module and see if that helps.

Thank you for your help.
prm

JonPeltier
10-24-2005, 05:49 AM
In the UserForm_Activate event procedure, use code like

TextBox1.Value = Worksheets("Praca").Range("E3").Value

Then in CommandButton1_Click (the OK or Apply button), use this to populate the workbook:

Worksheets("Praca").Range("E3").Value = TextBox1.Value

to populate the form's controls. This allows you to change values in textboxes, then cancel the form without changing the workbook.

If all of the data is in a contiguous range in the worksheet, you can load it in one step into a VBA array, and update the sheet in one step, which will speed up the process considerably.

prm
10-24-2005, 08:08 AM
Thanks Jon! That is what I needed to fix it.

prm