PDA

View Full Version : Excel VBA to server



.Snipe
03-08-2007, 03:08 AM
Hi VBAExpress team.

I need some help. I've been looking on the web for some solutions to my problem I can't seem to find any, or if I find it , it don't seem to work.

My situation is as following. I have a couple of excel files with VBA code, and at the end of everyday it processes all the data that has been entered during the day and saves it. After that I have to e-mail a couple of files. Now the thing that I want to do is create a VBA code that after the prossesing has been done, for the file to be uploaded at the press of a button to a certain server (with user and password protection) and overwrite the existing file on the server.

I tryed a couple of codes, but they did not work for me. I desperatly need some help, cause the unefficient work process is killing me.

Thank you.

Charlize
03-08-2007, 03:33 AM
Do you mean by using some sort of ftp-protocol that connects to your ftp-server. Take a look at this one : http://www.xcelfiles.com/Excel02.html#anchor_35

Charlize

.Snipe
03-08-2007, 04:18 AM
Thanks a million. Seems to work fine. Will work on it a couple of days, but you just gave me hope back :-)

.Snipe
03-08-2007, 04:59 AM
One more question.

I have the following script :

a=10
b=10
c=10
d=20

With [C2].Validation
.Delete
.add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="=D1: D1"
.IgnoreBlank = False
.InCellDropdown = True
.ErrorTitle = "ERROR"
'.InputMessage = "Select from list"
.ErrorMessage = "Please select from dropdown list only"
.ShowInput = True
.ShowError = True
End With

The question is : How can I put a variable in the formula ?
I need it to be something like this :

Operator:=xlBetween, Formula1:="=ab:cd" where ab would be like Cells(a,b)
meaning ab=J10 and cd=T10, so instead of
Operator:=xlBetween, Formula1:="=J10:T10" i can put in the variables.

Any ideas ?

.Snipe
03-08-2007, 05:10 AM
Got it ... I think. Work for me anyway.

u = Cells(10, 10).Address(RowAbsolute:=False, columnAbsolute:=False)
uu = Cells(aa, bb).Address(RowAbsolute:=False, columnAbsolute:=False)

With [C2].Validation
.Delete
.add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="=" & u & ":" & uu
.IgnoreBlank = False
.InCellDropdown = True
.ErrorTitle = "ERROR"
'.InputMessage = "Select from list"
.ErrorMessage = "Please select from dropdown list only"
.ShowInput = True
.ShowError = True
End With

Charlize
03-08-2007, 06:34 AM
Sub testing()
Dim rangetovalidate As Range
Dim rng As Range
Dim validlist As String
Set rangetovalidate = Application.InputBox("Select range where validationlist" & vbCrLf & _
"will be used ... (by using your mouse)", "Give range for list to be used.", , , , , , 8)
validlist = InputBox("Type in the range you want to use as validationlist", _
"Give validationlistrange ...", "=J10:M10")
For Each rng In rangetovalidate
With rng.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:=validlist
.IgnoreBlank = False
.InCellDropdown = True
.ErrorTitle = "ERROR"
.ErrorMessage = "Please select from dropdown list only"
.ShowInput = True
.ShowError = True
End With
Next rng
End SubCharlize