<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; Personal.xlsb на несколько определенных книг]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=14174&amp;type=atom" />
	<updated>2018-09-17T14:13:23Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=14174</id>
		<entry>
			<title type="html"><![CDATA[Re: Personal.xlsb на несколько определенных книг]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=128754#p128754" />
			<content type="html"><![CDATA[<p><strong>alexii</strong></p><p>Спасибо большое, уже разобрался</p>]]></content>
			<author>
				<name><![CDATA[inseption86]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=38818</uri>
			</author>
			<updated>2018-09-17T14:13:23Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=128754#p128754</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Personal.xlsb на несколько определенных книг]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=128753#p128753" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>inseption86 пишет:</cite><blockquote><p>- код не работает ни в одной из книг</p></blockquote></div><p>Что значит «не работает»? Что Вы хотели получить этим кодом? Смотрите, имя не может быть одновременно и &quot;1.xlsx&quot;, и &quot;2.xlsx&quot;, правильно? Рассмотрим три варианта:</p><p>1. Имя == &quot;1.xlsx&quot;. Тогда Sh.Parent.Name &lt;&gt; &quot;1.xlsx&quot; — ложно, Sh.Parent.Name &lt;&gt; &quot;2.xlsx&quot; — истинно. Ложь ИЛИ Истина ==&gt; Истина, выход из процедуры.</p><p>2. Имя == &quot;2.xlsx&quot;. Тогда Sh.Parent.Name &lt;&gt; &quot;1.xlsx&quot; — истинно, Sh.Parent.Name &lt;&gt; &quot;2.xlsx&quot; — ложно. Истина ИЛИ Ложь ==&gt; Истина, выход из процедуры.</p><p>3. Имя == чему-либо ещё. Тогда Sh.Parent.Name &lt;&gt; &quot;1.xlsx&quot; — истинно, Sh.Parent.Name &lt;&gt; &quot;2.xlsx&quot; — истинно. Истина ИЛИ Истина ==&gt; Истина, выход из процедуры.</p><p>Таким образом, какое бы ни было имя — с таким кодом всегда будет происходить выход из процедуры.</p><br /><p>Полагаю, Вы хотели получить нечто наподобие:<br /></p><div class="codebox"><pre><code>    If Not (Sh.Parent.Name = &quot;1.xlsx&quot; Or Sh.Parent.Name = &quot;2.xlsx&quot;) Then
        Exit Sub
    End If
</code></pre></div><p>или:<br /></p><div class="codebox"><pre><code>    If Sh.Parent.Name &lt;&gt; &quot;1.xlsx&quot; And Sh.Parent.Name &lt;&gt; &quot;2.xlsx&quot;) Then
        Exit Sub
    End If
</code></pre></div><p>или, для большей наглядности:<br /></p><div class="codebox"><pre><code>    Select Case Sh.Parent.Name
        Case &quot;1.xlsx&quot;, &quot;2.xlsx&quot;
            &#039; Nothing to do
        Case Else
            Exit Sub
    End Select
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2018-09-17T14:11:25Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=128753#p128753</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Personal.xlsb на несколько определенных книг]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=128751#p128751" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>If Sh.Parent.Name = &quot;1.xlsx&quot; Or Sh.Parent.Name = &quot;2.xlsx&quot; Then
Else
 Exit Sub
 End If</code></pre></div>]]></content>
			<author>
				<name><![CDATA[inseption86]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=38818</uri>
			</author>
			<updated>2018-09-17T14:02:39Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=128751#p128751</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Personal.xlsb на несколько определенных книг]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=128747#p128747" />
			<content type="html"><![CDATA[<p>Добрый день! Подскажите, пож-та, возможно ли&nbsp; использование этого кода в нескольких книгах ? Заранее спасибо!</p><div class="codebox"><pre><code>Dim WithEvents App As Application
  
Private Sub Workbook_Open()
  Set App = Application
End Sub
Private Sub App_SheetChange(ByVal Sh As Object, ByVal Target As Range)
&#039; только в определенном файле
  If Sh.Parent.Name &lt;&gt; &quot;1.xlsx&quot; Then Exit Sub
On Error Resume Next
    If Target.Count &gt; 1 Then Exit Sub
    &#039; запрет на ввод русских букв в столбце 3  (фио на англ)
    If Target.Column = 3 Then
        If Target Like &quot;*[А-Яа-яЁё]*&quot; Then
            &#039; если есть хоть одна русская буква
            MsgBox &quot;Ввод русских букв недопустим!&quot;, vbCritical
            Target.Value = &quot;&quot;        &#039; очистка ячейки
       End If
    End If
     
    If Target.Column = 2 Then
        If Target Like &quot;*[A-Za-zEe]*&quot; Then
            &#039; если есть хоть одна англ буква
            MsgBox &quot;Ввод английских букв недопустим!&quot;, vbCritical
            Target.Value = &quot;&quot;        &#039; очистка ячейки
       End If
    End If
End Sub</code></pre></div><br /><div class="codebox"><pre><code>If Sh.Parent.Name &lt;&gt; &quot;1.xlsx&quot; or Sh.Parent.Name &lt;&gt; &quot;2.xlsx&quot; Then Exit Sub</code></pre></div><p> - код не работает ни в одной из книг</p>]]></content>
			<author>
				<name><![CDATA[inseption86]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=38818</uri>
			</author>
			<updated>2018-09-17T13:28:06Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=128747#p128747</id>
		</entry>
</feed>
