Re: Convert Text Entered In Textbox
Does this help?
http://www.danielklann.com/exc…ext_in_a_vba_inputbox.htm
KJ.
Re: Convert Text Entered In Textbox
Does this help?
http://www.danielklann.com/exc…ext_in_a_vba_inputbox.htm
KJ.
Re: Msgbox Returning For Uknown Reason
Put an 'Exit Sub' after your Unload Me and before the ErrorHandler:
If i've explained that well enough!
HTH
KJ
Re: Force A Date Format
NP. You'll probably find out that it's down to Excel 'deciding' what you want the date to be rather than you being able to force it i.e. if you enter 12/01/2007 for January 12th it'll probably decide that you want 01/12/2007 (1st Dec).
Date/Time formats are still one of the most infuriating parts of Excel (although not necessarily a fault of the program).
KJ
Re: Force A Date Format
What error (if any) do you get? Seems to work okay for me, but there will likely be issues with Excel and it's Date/Time 'foibles'.
KJ
Re: Paste Special When Recording
Possibly because column F contains a lot of formulas, lookups etc.?
Works okay for me on a dodgy old Pentium III.
KJ
Re: Paste Special When Recording
Rather than select and paste try using
Dim f As Range
Dim colf As Range
Set colf = Range("F1:F65536")
For Each f In colf
f.Offset(0, -1).Value = f.Value
f.ClearContents
Next f
You can then put other checks on it to stop it from check once the last value in the column has been reached.
HTH
KJ
Re: Custom Date Format To Be Retained In .csv Also
Have you tried switching the lines around? i.e.
Haven't tested it myself, but I know the problems encountered with Date/Time format in Excel. Got to be worth a punt?
KJ
Re: Application-defined Or Object-defined Error
Works for me (albeit slightly butchered to remove uneeded code). Are you sure 'Sheet1' exists as that i.e. you haven't renamed another sheet to Sheet1 have you?
Out of curiosity, why do you bother with selecting "D15" on the added sheet and then select the activecell again after naming the sheet?
KJ
Re: Application-defined Or Object-defined Error
Edit
Kj
Re: Cell Format Dependant On Rows
I'm assuming you would want them to be the same colour as specific other cells in the row i.e. If A1 is 'None' and G1 is Yellow then you want A1 to be yellow, whereas if G1 is white then you want A1 to be white.
Would that be a correct assumption? If not then if you could provide a example that may help me get my head around it.
KJ
Re: Cell Format Dependant On Rows
What do you mean by 'default'?
KJ
Re: Double Click Hyperlink, Don't Folow On Single Click
I agree, I don't think it's possible. Every reference for Hyperlinks in Excel suggest that you can select the cell by holding the mouse button down for a time. Nothing suggests an alternative approach.
QuoteTo select a cell that has a hyperlink in it without jumping to the hyperlink destination, click the cell and hold the mouse button until the cursor becomes a cross , then release the mouse button.
KJ
Re: paste from workbook to workbook
Use
Dim wb, wb1 As Workbook
Dim ws, ws1 As Worksheet
Dim wsr As Range
Dim ilast, irow As Integer
Set wb = Workbooks("invoice&consignment.xls")
Set ws = Worksheets("inv & cons")
Set wb1 = Workbooks.Open("upload template.csv")
Set ws1 = Worksheets("upload template")
wb.Activate
irow = 3
ilast = ws.Range("D65536").End(xlUp).Row
Range("a" & irow & ":d" & ilast).Select
Selection.Copy
wb1.Activate
ws1.Range("A2").Select
ActiveSheet.Paste
Display More
HTH
EDIT: Got distracted while testing, God I was slow!!
KJ
Re: Link In A Message Box
Short answer, No.
However, there is a workaround (of a sort)
http://www.microsoft.com/techn…/qanda/oct04/hey1022.mspx
HTH
KJ
Re: Lock Cell After Entry
I think royUK's would likely work better and be more error free, but glad to have helped.
KJ
Re: Lock Cell After Entry
Well, if the workbook is protected then you can lock cells by using
Function InRange(Range1 As Range, Range2 As Range) As Boolean
'returns True if Range1 is within Range2
Dim InterSectRange As Range
Set InterSectRange = Application.Intersect(Range1, Range2)
InRange = Not InterSectRange Is Nothing
Set InterSectRange = Nothing
End Function
This allows you to specify a range in the below.
Private Sub Worksheet_Change(ByVal Target As Range)
If InRange(ActiveCell, Range("B1:B100")) Then
ActiveSheet.Unprotect
ActiveCell.Offset(-1, 0).Locked = True
ActiveSheet.Protect
Else: End If
End Sub
This will mean that if you enter something in B7 and press enter (and you have enter to drop down to next cell in column (default setting in Excel)) then cell B& will then have the attribute 'locked'.
If you're not protecting the workbook then it's likely a lot more complicated (certainly i'm stumped).
HTH
KJ
Re: Checking If A Value Is Present In A Cell If So Changing To The Cell Below
Sorry, forgot to add the original offset.
Private Sub CommandButton1_Click()
Range("B65536").End(xlUp).Offset(1, 0).Select
With ActiveCell
.Value = TextBox1.Value
.Offset(0, 1) = TextBox2.Value
.Offset(0, 2) = TextBox3.Value
'Add more Offsets here for each field in your input form.
End With
End Sub
That should work now.
KJ
Re: Checking If A Value Is Present In A Cell If So Changing To The Cell Below
QuoteIs working great! So if i wish to add more, i purely add more Offsets for the next textboxes
Yes.
QuoteI don't see the point in looping through the cells when .End(xlUp) finds the cell without. That's how I create all my Data Entry Forms
You're quite right royUK, my bad habits creeping in.
Private Sub CommandButton1_Click()
Range("B65536").End(xlUp).Select
With ActiveCell
.Value = TextBox1.Value
.Offset(0, 1) = TextBox2.Value
.Offset(0, 2) = TextBox3.Value
'Add more Offsets here for each field in your input form.
End With
End Sub
HTH
KJ
Re: Checking If A Value Is Present In A Cell If So Changing To The Cell Below
Okay, first off don't use TextBox1_change use
Private Sub TextBox1_AfterUpdate()
Dim targetrange As String
targetrange = Range("B3").Value
Do Until targetrange = ""
ActiveCell.Offset(1, 0).Select
targetrange = ActiveCell.Value
Loop
ActiveCell.Value = TextBox1.Value
End Sub
This will take you to the next available row in that column, and place the respective value in the cell.
There is probably a cleaner way of doing it by using ActiveCell.Offset and also using the 'Add to Database' button rather than using TextBox_afterupdate for each box.
e.g.
Private Sub CommandButton1_Click()
Dim targetrange As String
targetrange = Range("B3").Value
Do Until targetrange = ""
ActiveCell.Offset(1, 0).Select
targetrange = ActiveCell.Value
Loop
With ActiveCell
.Value = TextBox1.Value
.Offset(0, 1) = TextBox2.Value
.Offset(0, 2) = TextBox3.Value
'Add more Offsets here for each field in your input form.
End With
End Sub
Display More
HTH
KJ
Re: Checking If A Value Is Present In A Cell If So Changing To The Cell Below
Are you able to attach a sample workbook? I must be missing something because that is what the code I suggested should do.:confused:
KJ