|
本帖最后由 lengcj 于 2018-3-9 00:40 编辑
vba程序从一个表截取copy日期字段,然后复制到另一个表的单元格,过去自动添加星期几了
相关代码如下
If sht1.Cells(3, 3) = "放送曜日" Then
sht1.Cells(30, 7) = sht1.Cells(3, 4): sht1.Cells(3, 4) = "": sht1.Cells(3, 3) = ""
Else
If sht1.Cells(4, 3) = "放送曜日" Then
sht1.Cells(30, 7) = sht1.Cells(4, 4): sht1.Cells(4, 4) = "": sht1.Cells(4, 3) = ""
Else
End If
End If
*************
hangsht2 = 2 '取首播日期
Do Until sht1.Cells(hangsht2, 1) = "放映日" Or hangsht2 >= hangsht1
hangsht2 = hangsht2 + 1
Loop
'hangsht2 = 340
If InStr(sht1.Cells(hangsht2, 2), "~") = 0 Then
a = InStr(sht1.Cells(hangsht2, 2), "~")
sht1.Cells(hangsht1, 6) = sht1.Cells(hangsht2, 2)
sht1.Cells(hangsht1, 6).NumberFormatLocal = "yyyy-m-d"
a = sht1.Cells(hangsht1, 6)
End If
If InStr(sht1.Cells(hangsht2, 2), "~") > 0 Then
a = InStr(sht1.Cells(hangsht2, 2), "~")
sht1.Cells(hangsht1, 6) = Mid(sht1.Cells(hangsht2, 2), 1, a - 1)
sht1.Cells(hangsht1, 6).NumberFormatLocal = "yyyy-m-d"
k1 = sht1.Cells(hangsht1, 6)
sht1.Cells(hangsht1, 11) = Mid(sht1.Cells(hangsht2, 2), a + 1, Len(sht1.Cells(hangsht2, 2)))
sht1.Cells(hangsht1, 11).NumberFormatLocal = "yyyy-m-d"
k2 = sht1.Cells(hangsht1, 11)
End If
For k = 1 To 20
sht3.Cells(hangsht2, k) = Mid(sht1.Cells(hangsht1, k), 1, Len(sht1.Cells(hangsht1, k))): sht1.Cells(hangsht1, k) = ""
Next k
以前的电脑运行得很正常的,后来换了个电脑就开始多了星期几,office2003也重装了还是多了星期几成了这样【
】。郁闷啊~
出演.rar
(23.76 KB, 下载次数: 5)
|
|