LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default cell top of screen

I get cst02

"Gary''s Student" wrote:

Now to debug:

replace your line:

costid = xcell.Offset(0, 1)

with these two lines:

costid = xcell.Offset(0, 1).Value
Msgbox(costid)

tell me what happens.
--
Gary''s Student - gsnu200768


"ranswert" wrote:

I tried that and I still get an error. Here is the whole procedure and maybe
this will help:

Private Sub CommandButton1_Click()
Dim a2 As String
Dim b2 As String
Dim costitem As String
Dim rng As Range
Dim codeno As String
Dim ctr As Integer
Dim b1 As String
Dim a1 As String
Dim xcell As Range
Dim ycell As Range
Dim costid As String
Set xcell = ActiveCell
costid = xcell.Offset(0, 1)
'Set ycell = Range(costid)
a1 = Editcostitem.Label2.Caption
b1 = Editcostitem.Label6.Caption
a2 = Editcostitem.TextBox1.Value
b2 = Editcostitem.TextBox2.Value
ctr = 0
If a1 = a2 And b1 = b2 Then
MsgBox ("No changes selected for '" & b1 & " " & a1 & "' cost item")
Else
Sheets("Cost Details").Select
Set ycell = Range(costid)
Application.Goto ycell, Scroll:=True


ActiveWindow.Zoom = 75
Editcostitem.Hide
msg = MsgBox("There might be Cost Detail Items associated with this
Cost Item. Do you still want to change? ", vbYesNo)
ActiveWindow.Zoom = 100
Sheets("estimate costs").Select
xcell.Select
If msg = 6 Then
If a1 = a2 Then
For Each rng In Range("costcoderng").Cells
If rng.Value = b2 Then
ctr = ctr + 1
End If
Next
If ctr = 0 Then
xcell.Offset(0, -1) = b2
Else
MsgBox ("Cost Code '" & b2 & "' already exists")
End If
End If
If b1 = b2 Then
For Each rng In Range("costitemrng").Cells
If rng.Value = a2 Then
ctr = ctr + 1
End If
Next
If ctr = 0 Then
xcell = a2
Else
MsgBox ("Cost Item '" & a2 & "' already exists")
End If
End If
If a1 < a2 And b1 < b2 Then
For Each rng In Range("costcoderng").Cells
If rng.Value = b2 Then
ctr = ctr + 1
End If
Next
If ctr = 0 Then
xcell.Offset(0, -1) = b2
Else
MsgBox ("Cost Code '" & b2 & "' already exists")
End If
For Each rng In Range("costitemrng").Cells
If rng.Value = a2 Then
ctr = ctr + 1
End If
Next
If ctr = 0 Then
xcell = a2
Else
MsgBox ("Cost Item '" & a2 & "' already exists")
End If
End If
End If

End If


Editcostitem.Hide

End Sub



"Gary''s Student" wrote:

We are almost the

Sub demo()
Dim costid As String

'''''''''''''''''''''''''''
i = 1
If i = 1 Then
costid = "cst01"
Else
costid = "cst02"
End If
''''''''''''''''''''''''''

Set ycell = Range(costid)
Application.Goto ycell, scroll:=True
End Sub

This may look a little dumb, but it works. In your code you would naturally
set costid based upon real criteria, not the dumb if.
--
Gary''s Student - gsnu200768

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Arrow keys move screen instead of moving from cell to cell LuisGe Excel Discussion (Misc queries) 3 May 22nd 09 11:17 PM
Inputbox Location on Screen. Can you code it to popup lower on the screen ? Corey Excel Programming 3 December 13th 06 11:33 PM
print box opens in right screen of dual screen setup why gerrys Excel Discussion (Misc queries) 1 June 30th 06 06:47 PM
Arrow keys move screen instead of moving from cell to cell. JaJay777 Setting up and Configuration of Excel 1 January 17th 05 06:48 PM
How to copy data from excel to power point screen by screen? luvgreen[_3_] Excel Programming 0 April 9th 04 03:51 PM


All times are GMT +1. The time now is 02:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"