![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Posts: 117
|
hi-
To the much appreciation of mudface and Russell, I was able to use a code in my project as follows: Private Sub CommandButton3_Click() For Each C In Worksheets("BALANCE SHEET").Range("D1:D10000") ' Adjust your range if necessary If C.Value = DateForm.Calendar2.Value Then C.End(xlToRight).Offset(0, 1).Value = TextBox1.Text End If Next C End Sub Im using the calendar control on a userform to seek a date on column "D" of a worksheet. My request was how to write a code that will identify the first empty cell in that row(to the right of the date column)so that the text in textbox1 will be posted to that empty cell. So this means that the text from textbox1 will be inserted into column "E" on the row that coresponds to the date that was chosen using the calander control(asuming that column "e" is empty).THIS WORKS GREAT!! But heres the problem- lets say I want to insert that same info from textbox1 to column "K" even though column "E:J" are empty. Now I know I can use the offset methode to change the numbers from (0, 1) to (0, 7), but then the code wont search for the next available cell if column "k" is nonempty- it will just replace the info! Help anyone please? |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Portland, OR USA
Posts: 1,374
|
Quote:
Code:
If c.Offset(0, 7).Text = "" Then
c.Offset(0, 7).Text = TextBox1.Text
Else
c.Offset(0, 7).End(xlToRight).Offset(0, 1).Value = TextBox1.Text
End If
Russell [ This Message was edited by: Russell Hauf on 2002-02-26 08:42 ] |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|