Jump to content

VBA переносы


Vlad
 Share

Recommended Posts

Помогите в коде на VBA сделать переносы. В процессе потерялись, а Бейсик никто не знает. Надо расставить переносы, чтобы в рабочую программу превратился код. 

Private Sub Worksheet_Change(ByVal Target As Range)Dim vValDim StrVal As StringDim dDate As Date If Target.Cells.Count > 1 Then Exit Sub If Not Intersect(Target, Range("A2:A10")) Is Nothing Then With Target StrVal = Format(.Text, "000000") If IsNumeric(StrVal) And Len(StrVal) = 6 Then Application.EnableEvents = False dDate = DateValue(Left(StrVal, 2) & "/" & Mid(StrVal, 3, 2) & "/" & Right(StrVal, 2)) .NumberFormat = "dd/mm/yyyy" .Value = CDate(DateSerial(Year(dDate), Month(dDate), Day(dDate))) End If End With End If If Not Intersect(Target, Range("B2:B10")) Is Nothing Then With Target vVal = Format(.Value, "0000") If IsNumeric(vVal) And Len(vVal) = 4 Then Application.EnableEvents = False .Value = Left(vVal, 2) & ":" & Right(vVal, 2) .NumberFormat = "[h]:mm" End If End With End If Application.EnableEvents = TrueEnd Sub
Link to comment
Share on other sites

а Бейсик никто не знает.

я знает =) На скорую руку

Private Sub Worksheet_Change(ByVal Target As Range)    Dim vValDim StrVal As StringDim dDate As Date     If Target.Cells.Count > 1 Then Exit Sub     If Not Intersect(Target, Range("A2:A10")) Is Nothing Then         With Target             StrVal = Format(.Text, "000000")             If IsNumeric(StrVal) And Len(StrVal) = 6 Then                 Application.EnableEvents = False                 dDate = DateValue(Left(StrVal, 2) & "/" & Mid(StrVal, 3, 2) & "/" & Right(StrVal, 2))                 .NumberFormat = "dd/mm/yyyy"                 .Value = CDate(DateSerial(Year(dDate), Month(dDate), Day(dDate)))             End If         End With     End If     If Not Intersect(Target, Range("B2:B10")) Is Nothing Then         With Target             vVal = Format(.Value, "0000")             If IsNumeric(vVal) And Len(vVal) = 4 Then                 Application.EnableEvents = False                 .Value = Left(vVal, 2) & ":" & Right(vVal, 2)                 .NumberFormat = "[h]:mm"             End If         End With     End If     Application.EnableEvents = TrueEnd Sub
  • Like 2
Link to comment
Share on other sites

Такой понятный язык на первый взгляд)

VBA вообще очень понятный язык... правда когда меня пытались обучить ему в 7 классе - я ничего не понимал в нем... лет через пять только когда самостоятельно его разбирать начал пришло понимание )) 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy