VBA表列/行转换和更改货币

发布于 2024-11-08 05:20:18 字数 609 浏览 0 评论 0原文

我在 VBA 中有一个作业,必须将现有表的行转换为列,但我只需显示表中的两行,所有这些都必须在 ActiveX 控件按钮的帮助下完成。我还必须通过按钮将表格单元格值更改为欧元,然后再更改回爱沙尼亚克朗。第三,我必须根据新表找到它的价值和价格。

我已经尽可能地编写了代码,但它无法正常工作。有几个问题:a)首先,按下求解按钮后,它不会给出新表中的所有值,b)其次,当我尝试使用货币更改按钮欧元/克朗时,它会无限地乘以我的值,第三,当我必须找到最便宜的短信套餐名称及其价格时,我没有得到正确的答案。

我想我的解释非常混乱,所以我添加了可以在此处看到的 Excel 文件: http://www.2shared.com/file/awEG5hf-/KT_online.html

代码真的很长,所以我不想在这里添加它,但是作业中的图像看起来像这样: 在此处输入图像描述 该图像显示了作业的正确解决方案。

如果有人能抽出时间来帮助我,我真的非常非常感激。非常感谢。

I have got an assignment in VBA where I have to convert an existing table's rows to colums, but I only have to show two rows from the table and all that has to be done with the help of an ActiveX control button. I also have to change the table cells values to Euros and back to Estonian Kroons with the help of a button. Thirdly, I have to find a value and the price of it according to the new table.

I have already written the code as much as I could, but it does not work correctly. There are a few problems: a)firstly, after pressing the solving button it does not give all the values in the new table, b)secondly, when I try to use the currency changing buttons Euros/Kroons, it multiplies my values infinitely and thirdly I do not get a right answer when I have to find the cheapest SMS package name and the price of it.

I guess my explanation was very messy, so I am adding the Excel file that can be seen here: http://www.2shared.com/file/awEG5hf-/KT_online.html

The code is really long, so I don't want to add it here, but the image from the assignment looks like this: enter image description here that image shows the correct solution of the assignment.

I really, really appreciate it if someone could find time to help me. A huge thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

请别遗忘我 2024-11-15 05:20:18

尝试更改以下子表

SHEET1

Private Sub CommandButton1_Click()
    If Sheet1.Range("E6").Value = "Prices in Euros" Or Sheet1.Range("E6").Value = ""    Then eek
End Sub

Private Sub CommandButton2_Click()
    If Sheet1.Range("E6").Value = "Prices in Kroons" Or Sheet1.Range("E6").Value = "" Then eur
End Sub

Private Sub CommandButton3_Click()
    lahenda
End Sub

MODULE1

Sub lahenda()

With Sheet1
    .Range("B8:B16,F8:F16").Copy
    .Range("B18:J19").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=True
    .Range("C23").Formula = "=MIN(H9:H16)"
    .Range("C24").Formula = "=INDEX(B9:B16,MATCH(minhind,H9:H16,0),1)"
End With

End Sub

MODULE2

Sub eur()
    Dim prk As Range, hinnad As Range, koht1
    Dim n, m
    Set prk = Range("alg").CurrentRegion
    n = prk.Rows.Count - 1
    m = prk.Columns.Count - 1
    Set hinnad = prk.Offset(1, 1).Resize(n, m)

    Set koht1 = prk.Cells(2, 2)

    ReDim a(1 To n, 1 To m), paketid(1 To n), naitajad(1 To m)
    ReDim veerg(1 To n), rida(1 To m)
    ReDim b(1 To n, 1 To m)

    a = hinnad

    kurss = Range("kurss")
    tee_tabel a(), n, m, b(), kurss
    tabel_lehele b(), n, m, koht1
 Sheet1.Range("E6").Value = "Prices in Euros"
End Sub

MODULE3

Sub eek()
    Dim prk As Range, hinnad As Range, koht1 As Range
    Dim n, m
    Set prk = Range("alg").CurrentRegion
    n = prk.Rows.Count - 1
    m = prk.Columns.Count - 1
    Set hinnad = prk.Offset(1, 1).Resize(n, m)

    Set koht1 = prk.Cells(2, 2)

    ReDim a(1 To n, 1 To m), paketid(1 To n), naitajad(1 To m)
    ReDim veerg(1 To n), rida(1 To m)
    ReDim b(1 To n, 1 To m)

    a = hinnad

    kurss = Range("kurss")
    tee_tabel a(), n, m, b(), kurss
    tabel_lehele b(), n, m, koht1
 Sheet1.Range("E6").Value = "Prices in Kroons"
End Sub

Try changing the following subs

SHEET1

Private Sub CommandButton1_Click()
    If Sheet1.Range("E6").Value = "Prices in Euros" Or Sheet1.Range("E6").Value = ""    Then eek
End Sub

Private Sub CommandButton2_Click()
    If Sheet1.Range("E6").Value = "Prices in Kroons" Or Sheet1.Range("E6").Value = "" Then eur
End Sub

Private Sub CommandButton3_Click()
    lahenda
End Sub

MODULE1

Sub lahenda()

With Sheet1
    .Range("B8:B16,F8:F16").Copy
    .Range("B18:J19").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=True
    .Range("C23").Formula = "=MIN(H9:H16)"
    .Range("C24").Formula = "=INDEX(B9:B16,MATCH(minhind,H9:H16,0),1)"
End With

End Sub

MODULE2

Sub eur()
    Dim prk As Range, hinnad As Range, koht1
    Dim n, m
    Set prk = Range("alg").CurrentRegion
    n = prk.Rows.Count - 1
    m = prk.Columns.Count - 1
    Set hinnad = prk.Offset(1, 1).Resize(n, m)

    Set koht1 = prk.Cells(2, 2)

    ReDim a(1 To n, 1 To m), paketid(1 To n), naitajad(1 To m)
    ReDim veerg(1 To n), rida(1 To m)
    ReDim b(1 To n, 1 To m)

    a = hinnad

    kurss = Range("kurss")
    tee_tabel a(), n, m, b(), kurss
    tabel_lehele b(), n, m, koht1
 Sheet1.Range("E6").Value = "Prices in Euros"
End Sub

MODULE3

Sub eek()
    Dim prk As Range, hinnad As Range, koht1 As Range
    Dim n, m
    Set prk = Range("alg").CurrentRegion
    n = prk.Rows.Count - 1
    m = prk.Columns.Count - 1
    Set hinnad = prk.Offset(1, 1).Resize(n, m)

    Set koht1 = prk.Cells(2, 2)

    ReDim a(1 To n, 1 To m), paketid(1 To n), naitajad(1 To m)
    ReDim veerg(1 To n), rida(1 To m)
    ReDim b(1 To n, 1 To m)

    a = hinnad

    kurss = Range("kurss")
    tee_tabel a(), n, m, b(), kurss
    tabel_lehele b(), n, m, koht1
 Sheet1.Range("E6").Value = "Prices in Kroons"
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文