עבור לתוכן

שאלה בקשר לקבל קלט במקרואים של אקסל

Featured Replies

פורסם

שלום לכולם,

אני משתמש בגרסה האנגלית של אקסל, ואני רוצה לקבל קלט מחרוזת מהמשתמש. אני משתמש בפעולה inputbox. הבעיה היא, שכשאני מנסה לכתוב בעברית, בחלון שאליו אני כותב הוא כותב ג'יבריש, ואז המקרו לא עובד. הערה- הרגע ניסיתי להעתיק דוגמא למה שמופיע בחלון של הקלט, אבל פה זה הופיע בעברית נורמלית.

פורסם
  • מחבר

תודה על העזרה, אבל חשבתי על דרך יותר פשוטה. אני יכול לבקש שהמשתמש יכתוב את המחרוזת בתא A,1, ואז אני אוכל פשוט ללכת לתא הזה ולהשתמש בערך שם. הבעיה היא שזה לא עובד. להלן קטע הקוד:

Sub SearchForString()

Dim LSearchRow As Integer

Dim LCopyToRow As Integer

Dim searchValue As String

Dim searchColumn As String

On Error GoTo Err_Execute

'Start search in row 2

LSearchRow = 2

'Start copying data to row 2 in Sheet2 (row counter variable)

LCopyToRow = 2

'get input

searchValue = Range("A" & CStr(1)).Value

searchColumn = InputBox(Prompt:="please enter the column to look at", Title:="search column")

While Len(Range("A" & CStr(LSearchRow)).Value) > 0

'If value in column searchColumn = searchValue, copy entire row to Sheet2

If Range(searchColumn & CStr(LSearchRow)).Value = searchValue Then

'Select row in Sheet1 to copy

Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select

Selection.Copy

'Paste row into Sheet2 in next row

Sheets("Sheet2").Select

Rows(CStr(LCopyToRow) & ":" & CStr(LCopyToRow)).Select

ActiveSheet.Paste

'Move counter to next row

LCopyToRow = LCopyToRow + 1

'Go back to Sheet1 to continue searching

Sheets("Sheet1").Select

End If

LSearchRow = LSearchRow + 1

Wend

'Position on cell A3

Application.CutCopyMode = False

Range("A3").Select

MsgBox "All matching data has been copied."

Exit Sub

Err_Execute:

MsgBox "An error occurred."

End Sub

המקרו אמור לעבור על הטבלה ולהעתיק כל שורה עם המחרוזת שאני מחפש לדף 2. אני לא כ"כ מבין במקרואים של אקסל, ואת רוב הקוד מצאתי באינטרנט, אז כנראה זו פשוט שגיאה מטומטמת...

פורסם
  • מחבר

אני לא רוצה להשמע לחוץ, אבל אני קצת צריך לפתור את בזמן הקרוב, אז אם מישהו יכול לעזור לי אני אשמח מאוד...

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים