View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
FSt1 FSt1 is offline
external usenet poster
 
Posts: 3,942
Default VBA - passing Variables to subroutines

hi
in gemwon2_click, you have.......
Gemloc = 13 'Column M
Gemnumloc = 4 ' Row 4


in submitbutton_click,you have......
Cells(Gemloc, Gemnumloc).Value = Gemname.Value


this is backwards. if gemloc is the column and gemnumloc is the row it
should be
cell(gemnumloc,gemloc).value = gemname.value
so the value is goint to d13 not m4.
what is gemname. are you sure gemid is returning a value. i can't test that.

regards
FSt1

"Madduck" wrote:

HI I'm having a problem passing variable values around ..

I've done this

Option Explicit
Public Gemloc As Integer
Public Gemnumloc As Integer

Private Sub Gemwon2_Click()

Sheets("Rift_raid").Visible = True
Gemloc = 13 'Column M
Gemnumloc = 4 ' Row 4

Gemlist.Show

End Sub

Gemlist is a form that has a list box where you can select an item and on
submit uses this code

Sub SubmitButton1_Click()
Sheets("Rift_raid").Select

Gemid ' calls a subroutine in the form that gives an item a value.

Cells(Gemloc, Gemnumloc).Value = Gemname.Value

Range("o1") = ""
Gemname.Value = ""
Gemname.Clear
Gemlist.Hide

End Sub

What I want it to do is to place the Item name in Cell (Gemloc, Gemnumloc)
and the item value in the next cell.. but for some reason both Gemloc and
Gemnumloc are not getting passed from the Sheet to the form's subrountine..

Does this make sence?

Thanks