|
学习编码====
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim c&
'Sheets("录入表").Select
c = Range("v3").Value
If Target.Column <> 4 Or Target.Row <> c + 5 Then Exit Sub
a = Range("u4").Value
b = Range("v4").Value
Range(a).Select
Application.CutCopyMode = False
Selection.copy
Sheets("数据总表").Select
ActiveSheet.Range(b).Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=True
Sheets("录入表").Select
'ActiveSheet.Paste
Application.CutCopyMode = False
Range(a).Select
Selection.ClearContents
Range("D8:D14").FormulaR1C1 = "=RC[16]:R[6]C[16]"
Range("D17").FormulaR1C1 = "=RC[16]"
Range("D5").Select
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 4 Then Exit Sub
If (Target.Column = 4) Then
Select Case Target.Row
'Case 5
'Target.NumberFormatLocal = "0"
Case 7
Select Case Target
Case "1"
Target = "建安"
Case "2"
Target = "房开(民居)"
Case "3"
Target = "房开(商用)"
End Select
Case 16
Target.NumberFormatLocal = "G/通用格式"
If Len(Target) = 8 And IsNumeric(Target) Then
Target = Left(Target, 4) & "-" & Mid(Target, 5, 2) & "-" & Right(Target, 2)
End If
Target.NumberFormatLocal = "yyyy-mm-dd"
End Select
End If
End Sub
===========
Private Sub CommandButton1_Click()
Dim ccount&
Sheets("数据总表").Select
ccount = [c7].CurrentRegion.Columns.Count
Range("c7").Resize(, ccount).Select
Selection.copy
Sheets("录入表").Select
ActiveSheet.Range("c5").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Application.CutCopyMode = False
ActiveSheet.Cells(ccount + 5, 4).Select
With Selection.Interior
.ColorIndex = 38
.Pattern = xlSolid
End With
ActiveSheet.Range("v3") = ccount
End Sub
==================
|
|