Here is the attachment
Posts by marav08
-
-
Hi,
I'm trying to average a cell that has a formula but i'm getting an error of #DIV/0!
-
Here it is sir. there is a value in M4. but you can check the file here
-
All criteria ranges need to be the same size.
What you can do is add a helper column, at M4 enter formula: =COUNTIF(I4:L4,"No") copied down.
then you can adjust your formula to:
=COUNTIFS(Sheet3!$C$4:$C$1048576,Sheet3!$C$4,Sheet3!$E$4:$E$1048576,Sheet3!E4,Sheet3!$M$4:$M$1048576,">0")
Do you mind if I attached my sample workbook here?
-
All criteria ranges need to be the same size.
What you can do is add a helper column, at M4 enter formula: =COUNTIF(I4:L4,"No") copied down.
then you can adjust your formula to:
=COUNTIFS(Sheet3!$C$4:$C$1048576,Sheet3!$C$4,Sheet3!$E$4:$E$1048576,Sheet3!E4,Sheet3!$M$4:$M$1048576,">0")
Sorry but i'm not quite getting it.
please correct me if i'm wrong. So I wlil be putting the =COUNTIF(I4:L4,"No") to what sheet? sheet4? and then the =countif(....) in sheet 4 as well? Am I right? sorry got a lil bit confused. -
-
I am on the active sheet where the data is coming from. I'm in sheet1 and wanted to paste it on sheet 2.
here is an example workbook of what i'm trying to do. -
Hi,
This works perfectly. one last question sir. Example is I want to copy b4 in sheet one together with all the cells i have and then paste it on sheet 3 which is in E and then right after that the D10 will be pasted in I. I mean is there a way to skip 3-4 cells?Oh after I deleted the data in sheet3 to try it again. the code doesn't seem to work.
-
Code
Sub This_Maybe() Dim rngArr rngArr = Array([D10], [D11], [D12], [D15], [D22], [D25], [D32], [D33], [D38], [D39], _ [D40], [D41], [D42], [D47], [D48], [D49], [D50], [D53], [D55], [D57], [D63], [G3]) Sheets("Sheet3").Cells(Rows.Count, 9).End(xlUp).Offset(1).Resize(, UBound(rngArr) + 1) = rngArr End Sub
Hi,
This works perfectly. one last question sir. Example is I want to copy b4 in sheet one together with all the cells i have and then paste it on sheet 3 which is in E and then right after that the D10 will be pasted in I. I mean is there a way to skip 3-4 cells? -
Code
Sub This_Maybe() Dim rngArr rngArr = Array([D10], [D11], [D12], [D15], [D22], [D25], [D32], [D33], [D38], [D39], _ [D40], [D41], [D42], [D47], [D48], [D49], [D50], [D53], [D55], [D57], [D63], [G3]) Sheets("Sheet3").Cells(Rows.Count, 9).End(xlUp).Offset(1).Resize(, UBound(rngArr) + 1) = rngArr End Sub
I'm currently not infront of my work computer right now. be there in 15mins. i'll try this one out. I'll update you what happened. thanks
-
Hi,
I've been trying to copy multiple cells from sheet 1 to sheet 3. But every time that I will add a cell on the range it is giving me an error message "That Command cannot be used on multiple selections."
There are also other cell that I want to copy and paste it on a specific cell in sheet3
for example
Sheet1: b4 and b6 I need to paste it in sheet3 cell is E4 and B4so the B4 in sheet 1 should be pasted in sheet3 E4 and b6 should be pasted in B4.
Code
Display MoreSub Button40_Click() Range("D10:D12,D15,D22,D25,D32:D33,D38:D42,D47:D50,D53,D55,D57,D63,G3").Select Selection.Copy Sheets("Sheet3").Select 'Range("I4").End(xlUp).Select lMaxRows = Cells(Rows.Count, "I").End(xlUp).Row Range("I" & lMaxRows + 1).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=True Sheets("Sheet1").Select Range("I4").Select End Sub
-
Hi I tried it and it is working.
do you have the time to explain how it worked? -
OK, thanks. What problem exactly are you having with your code? Are you able to attach a simplified workbook?
Here is my sample workbook.
For example I am searching a data with only name. it gives me an error type mismatch and it highlightswhat i'm trying to do is to search a file using Name and date range or by name only or only by date.
-
Sorry if i cross post. Here is the link. https://stackoverflow.com/questions/...being-searched
moving forward it won't happen again. -
Hi,
I'm trying to create a search button that will populate my listbox and textbox if try searching for date range or by name only or by date only or by name and date range. I already tried tweaking the codes but I cannot come up with the solution.
Here are my codes:Code
Display MorePrivate Sub cmdFind_Click() Dim DateRange As Range, rCl As Range, rng As Range, Dn As Range Dim Date1 As Date, Date2 As Date Dim iX As Integer Dim strName As String Dim nrows As Long Set DateRange = Sheet2.Range("A1").CurrentRegion.Columns(4) Me.ListBox1.Clear strName = Me.txtName.Value Date1 = CDate(Me.txtDate.Value) Date2 = CDate(Me.EndDate.Value) For Each rCl In DateRange.Cells If (rCl.Value >= Date1 And rCl.Value <= Date2) And (rCl.Offset(0, -3).Value = strName) Then If rCl.Value = "" Then With Me.ListBox1 .AddItem Sheet2.Cells(rCl.Row, 1) .List(.ListCount - 1, 1) = Sheet2.Cells(rCl.Row, 2) .List(.ListCount - 1, 2) = Sheet2.Cells(rCl.Row, 3) .List(.ListCount - 1, 3) = Sheet2.Cells(rCl.Row, 4) .List(.ListCount - 1, 4) = Sheet2.Cells(rCl.Row, 5) .List(.ListCount - 1, 5) = Format(Sheet2.Cells(rCl.Row, 6), "hh:mm:ss") End With End If End If Next rCl End Sub Private Sub EndDate_Exit(ByVal Cancel As MSForms.ReturnBoolean) With Me.EndDate If Len(.Value) = 0 Then Exit Sub If Not IsDate(.Value) Then MsgBox "Please enter a correctly formatted date" .Value = Empty .SetFocus End If Exit Sub End With End Sub Private Sub txtDate_Exit(ByVal Cancel As MSForms.ReturnBoolean) With Me.txtDate If Len(.Value) = 0 Then Exit Sub If Not IsDate(.Value) Then MsgBox "Please enter a correctly formatted date" .Value = Empty .SetFocus End If Exit Sub End With End Sub
-
Dir() was not meant to work with UNC paths. A FileSystemObject method will work.
I would use a window's API method to take care of that the way it does in normal practice.
If it were me, I would change the date format to yyyymmdd as it will sort better that way if you use name sorts.
If you want to pursue one or more of these ideas and get stuck, post back what you want.
I already have it working. :)) thanks for the reply anyways. here are the codes.
Code
Display MoreSub Button38_Click() Dim newFileName As String, strPath As String Dim strFileName As String, strFileName1 As String, strDate As String, strExt As String, strFullname As String strPath = "\\10.80.2.4\Shared Folder$\Acurus Folder Redirection\virgilio.beltran\Desktop\New folder\" strFileName = Range("B4") 'Change to suit strFileName1 = Range("B6") strDate = Format(Date, "ddmmyyyy") strExt = ".xls" 'Change to suit strFullname = strFileName & strFileName1 & strDate newFileName = strFullname & "-" & GetNewSuffix(strPath, strFullname, strExt) & strExt MsgBox "The new FileName is: " & newFileName, vbOKCancel 'Save copy ActiveWorkbook.SaveCopyAs strPath & newFileName End Sub Function GetNewSuffix(ByVal strPath As String, ByVal strFullname As String, ByVal strExt As String) As Integer Dim strFile As String, strSuffix As String, intMax As Integer On Error GoTo ErrorHandler 'File's name strFile = Dir(strPath & "\" & strFullname & "*") Do While strFile <> "" 'File's suffix starts 2 chars after 'root' name (right after the "-") strSuffix = Mid(strFile, Len(strFullname) + 2, Len(strFile) - Len(strFullname) - Len(strExt) - 1) 'FileName is valid if 1st char after name is "-" and suffix is numeric with no dec point 'Skip file if "." or "," exists in suffix If Mid(strFile, Len(strFullname) + 1, 1) = "-" And CSng(strSuffix) >= 0 And _ InStr(1, strSuffix, ",") = 0 And InStr(1, strSuffix, ".") = 0 Then 'Store the max suffix If CInt(strSuffix) >= intMax Then intMax = CInt(strSuffix) End If NextFile: strFile = Dir Loop GetNewSuffix = intMax + 1 Exit Function ErrorHandler: If Err Then Err.Clear Resume NextFile End If End Function
-
Hi,
I'm trying to create a button that will increment once the filename already exist. I can save the file for this but the number does not increment. I tried making some changes with the codes I got from the web. Thanks.
Code
Display MoreSub Button38_Click() Dim newFileName As String, strPath As String Dim strFileName As String, strFileName1 As String, strDate As String, strExt As String strPath = "\\10.80.2.4\Shared Folder$\Acurus Folder Redirection\virgilio.beltran\Desktop\New folder\" strFileName = Range("B4") 'Change to suit strFileName1 = Range("B6") strDate = Format(Date, "ddmmyyyy") strExt = ".xls" 'Change to suit newFileName = strFileName & "-" & strFileName1 & "-" & strDate & "-" & GetNewSuffix(strPath, strFileName, strFileName1, strDate, strExt) & strExt MsgBox "The new FileName is: " & newFileName, vbOKCancel 'Save copy ActiveWorkbook.SaveCopyAs strPath & newFileName End Sub Function GetNewSuffix(ByVal strPath As String, ByVal strName As String, ByVal strName1 As String, ByVal strDte As String, ByVal strExt As String) As Integer Dim strFile As String, strSuffix As String, intMax As Integer On Error GoTo ErrorHandler 'File's name strFile = Dir(strPath & "\" & strName & "\" & strName1 & "\" & strDte & "*") Do While strFile <> "" 'File's suffix starts 2 chars after 'root' name (right after the "-") strSuffix = Mid(strFile, Len(strName) + Len(strName1) + Len(strDte) + 2, Len(strFile) - Len(strName) - Len(strName1) - Len(strDte) - Len(strExt) - 1) 'FileName is valid if 1st char after name is "-" and suffix is numeric with no dec point 'Skip file if "." or "," exists in suffix If Mid(strFile, Len(strName) + Len(strName1) + Len(strDte) + 1, 1) = "-" And CSng(strSuffix) >= 0 And _ InStr(1, strSuffix, ",") = 0 And InStr(1, strSuffix, ".") = 0 Then 'Store the max suffix If CInt(strSuffix) >= intMax Then intMax = CInt(strSuffix) End If NextFile: strFile = Dir Loop GetNewSuffix = intMax + 1 Exit Function ErrorHandler: If Err Then Err.Clear Resume NextFile End If End Function
-
sorry if I posted on a different site. I did not know. I'm just desperate of seeking the possible answer to my concern. Once again sorry.
-
Hi,
please do correct if violate some rules. I have a workbook that needs to be saved everytime there is a new name that is selected and if ever that the same name will be save the file name will increment. The filename I choose is the value of cells. Name - Date - Line of business. so for eg. My first file is Ryan-07-21-2017-Tech. then I will be saving a file again with the same criteria it should now be Ryan-07-21-2017-Techv2. I already have a code but it seems that everytime I will be saving the same file name my excel file is not responding anymore and then is there a possible way as well the each time I save as a file my main workbook will not be closed? Thanks.
Below are my codes.Code
Display MoreSub Button38_Click() Dim i As Long Dim Path As String Dim FileName1 As String Dim FileName2 As String Dim nameDate As String Dim fn As String Dim check As String Dim ok As Boolean FileName1 = Range("B4") FileName2 = Range("B6") nameDate = Format(Date, "dd.mm.yyyy") Path = "\\10.80.2.4\Shared Folder$\Acurus Folder Redirection\virgilio.beltran\Desktop\New folder" fn = Path & FileName1 & "-" & FileName2 & "-" & nameDate & ".xlsm" check = Dir(fn) ok = (check = "") Do Until ok i = i + 1 fn = Path & FileName1 & "-" & FileName2 & "-" & nameDate & ".xlsm" check = Dir(fn) ok = (check = "") Loop ThisWorkbook.SaveAs fn 'ActiveWorkbook.SaveAs Filename:=Path & FileName1 & "-" & FileName2 & "-" & nameDate & ".xlsm", FileFormat:=xlNormal End Sub
-
Hi,
I'm trying to create a search button that will display the information on the list box. The data that i'm trying to search is by name and date range. or it can also by name or by date only. I'm already have a code but it seems that there is something wrong because everytime I tried searching it is displaying all the name but the date is correct.
Below are the codesCode
Display MorePrivate Sub cmdFind_Click() Dim DateRange As Range, rCl As Range, rng As Range, Dn As Range Dim Date1 As Date, Date2 As Date Dim iX As Integer Dim strName As String Set DateRange = Sheet2.Range("A1").CurrentRegion.Columns(4) Set rng = Sheet2.Range("A1").CurrentRegion.Columns(4) Me.ListBox1.Clear strName = Me.txtName.Text Date1 = CDate(Me.txtDate.Value) Date2 = CDate(Me.EndDate.Value) For Each rCl In DateRange.Cells For Each Dn In rng.Cells If rCl.Value >= Date1 And rCl.Value <= Date2 And strName Then ElseIf Dn.Value = strName Then With Me.ListBox1 .AddItem Sheet2.Cells(rCl.Row, 1) .List(.ListCount - 1, 1) = Sheet2.Cells(rCl.Row, 2) .List(.ListCount - 1, 2) = Sheet2.Cells(rCl.Row, 3) .List(.ListCount - 1, 3) = Sheet2.Cells(rCl.Row, 4) .List(.ListCount - 1, 4) = Sheet2.Cells(rCl.Row, 5) .List(.ListCount - 1, 5) = Format(Sheet2.Cells(rCl.Row, 6), "hh:mm:ss") End With End If Next Dn Next rCl End Sub