需要Range.text对象

时间:2017-07-20 14:45:37

标签: arrays excel vba text cell

我在尝试通过Range命令

修改Cell Text时遇到了一些问题

这里有代码。我正在制作一款基于回合制游戏的游戏。在第一个函数中,我初始化不同的数组。 listecase是一个二维数组,用于定义所有托盘盒的列表。 每个托盘都有不同的属性,首先我在单元格中有位置(例如,listecase(0,0)=“F69”,因为第一个托盘盒位于单元格F69中)

使用此方法我需要使用Range方法从托盘盒中访问文本。

Dim listecase(40, 11) As Variant
Dim joueur() As Integer
Dim tour As Integer

Sub lancer()
Dim de1 As Integer
Dim de2 As Integer
Randomize
de1 = Int(Rnd * 7)
de2 = Int(Rnd * 7)

Range(listecase(joueur(tour), 0)).Replace tour, "", xlWhole
MsgBox Range(listecase(joueur(tour), 0)).Text

'Throw the error here
Range(listecase(joueur(tour), 0)).Text = Trim(Range(listecase(joueur(tour), 0)).Text)
joueur(tour) = joueur(tour) + de1 + de2

'And here
Range(listecase(joueur(tour), 0)).Text = Range(listecase(joueur(tour), 0)).Text & " " & tour
Call jeux
End sub

我要解释一下我的代码。这个宏应该模拟掷骰子。然后它应该将玩家位置移动到好托盘盒。玩家的当前托盘盒可以在joueur()中找到,而tour是识别玩家应该玩的id。

我想要做的是,当我掷骰子时,它会自动删除托盘盒中的玩家编号,然后将其ID放入新玩家的托盘盒中。

好吧,我签署了抛出错误424对象所需的行

如果我不清楚我的解释并抱歉我的英语不好,我很抱歉

谢谢

0 个答案:

没有答案