返回列表 发帖

[问题求助] 求助VBS把三个分开的宏,合并成一个

我自己是先到网上去找了代码,然后根据需要,,定义了3个不同的宏,,,现在有点麻烦是每次要分别点三次,,生成对应的数据,,,,,能不能把他们合并到一起,,,,点那个"生成数据"按钮,,,,相应的数据生成列就去索引源数据,,,,如果源列有初始数据,,,就在对应的列生成符合格式的数据,,,谢谢

本帖最后由 soykoa 于 2022-7-17 20:34 编辑
Public Sub 自由流通盘()
  j = 2
          Do While Cells(j, 1) <> ""
     
      txtContent = Cells(j, 1)
         If Mid(Cells(j, 1), 1, 1) = "6" Then
         Cells(j, 10) = "SH" & Mid(txtContent, 1, 6)
         Cells(j, 11) = Cells(j, 2)
         
         Else
        Cells(j, 10) = "SZ" & Mid(txtContent, 1, 6)
        Cells(j, 11) = Cells(j, 2)
         
         End If
         
   
     j = j + 1
          Loop
End Sub
Public Sub 细分行业()
  j = 2
          Do While Cells(j, 4) <> ""
     
      txtContent = Cells(j, 4)
         If Mid(Cells(j, 4), 1, 1) = "6" Then
         Cells(j, 12) = "SH" & Mid(txtContent, 1, 6)
         Cells(j, 13) = Cells(j, 5)
         
         Else
        Cells(j, 12) = "SZ" & Mid(txtContent, 1, 6)
        Cells(j, 13) = Cells(j, 5)
         
         End If
         
   
     j = j + 1
          Loop
End Sub
Public Sub 主题概念()
  j = 2
          Do While Cells(j, 7) <> ""
     
      txtContent = Cells(j, 7)
         If Mid(Cells(j, 7), 1, 1) = "6" Then
         Cells(j, 14) = "SH" & Mid(txtContent, 1, 6)
         Cells(j, 15) = Cells(j, 8)
         
         Else
        Cells(j, 14) = "SZ" & Mid(txtContent, 1, 6)
        Cells(j, 15) = Cells(j, 8)
         
         End If
         
   
     j = j + 1
          Loop
End SubCOPY
这三段是我在网上找的一截代码自己改出来的三段,,,,怎么把这三段合并成一个代码,,,,只需要点一次,,,就分别去生成相应列的数据呢?

TOP

怎么不能上传附件了呢?

TOP

还真可以,,,谢谢老师!

TOP

返回列表