Get instant live expert help on I need help with vba dim as range

“My Excelchat expert helped me in less than 20 minutes, saving me what would have been 5 hours of work!”

Post your problem and you’ll get expert help in seconds.

Our professional experts are available now. Your privacy is guaranteed.

Here are some problems that our users have asked and received explanations on

Hi I have a piece of code that suddenly stop working: All code in the sheet...cell is not working Private Sub Receipt_Click() Dim customername As String Dim customeraddress As String Dim invoicenumber As String Dim r As Long Dim mydate As String Dim path As String Dim myfilename As String lastrow = Sheets("01").Range("B" & Rows.Count).End(xlUp).Row r = 5 For r = 5 To lastrow If Cells(r, 15).Value = "done" Then GoTo nextrow Product = Sheets("01").Range("R2").Value ...working studentname = Sheets("01").Cells(r, 2).Value...not working Cells(r, 15).Value = "done"...not working
Solved by E. D. in 14 mins
i need assist with some vba coding Dim ws As Worksheet Dim irow As Long Set ws = Sheets("sheet1") irow = ws.Cells(ws.Rows.Count, 1).End(x1up).Offset(1, 0).Row The last line keeps coming out as an error?
Solved by I. H. in 14 mins
Can you simplify this formula for vba? Sub Test() Dim LastRow As Long Dim i As Long LastRow = Range("A" & Rows.Count).End(xlUp).Row For i = 2 To LastRow If Range("A" & i).Value = "CANCELLED" Then Range("N" & i).Value = "," & Range("N" & i).Value Range("O" & i).Value = "," & Range("O" & i).Value Range("P" & i).Value = "," & Range("P" & i).Value Range("Q" & i).Value = "," & Range("Q" & i).Value Range("R" & i).Value = "," & Range("R" & i).Value End If Next i End Sub And skip if blank.
Solved by M. E. in 16 mins
I am trying to copy a range of cells, rows from one worksheet to another including the formatting and values. The code below is my latest attempt that is getting a subscript error. :( Dim SourceRange As Range Dim DestinationRange As Range Set SourceRange = Worksheets("ws1_ICE").Range("A1:J7") Set DestinationRange = Worksheets("ws2_TCO").Range("A1") SourceRange.Copy DestinationRange DestinationRange.PasteSpecial Paste:=xlPasteFormats DestinationRange.PasteSpecial Paste:=xlPasteValues
Solved by Z. B. in 30 mins
hi, I am stuck in a problem since one week and need help!!! I am running a SQL query in Excel 2010 VBA. The query runs fine but when I use GROUP BY, I get Automation Error. Everything works if I remove Group By but I need to group data. My query looks like: Dim objRs As New ADODB.Recordset Dim output As String Dim trows As Integer Dim ThisTab As Excel.Worksheet Dim tcols As Integer Dim i As Integer Dim sSQL As String ' sSQL = "SELECT * from [Data] where [Rem Scen 2] > 0 and (Now() - [Eval Date]) <=60" sSQL = "SELECT [Emp ID], [Deptt], [Job Types], [Join Date],[Pay 1]+[Pay 2] as [Compensate] from [Data] Group By {Emp ID] With objConn .Provider = "Microsoft.ACE.OLEDB.12.0" .ConnectionString = "Data Source=" & ThisWorkbook.Path & "\" & ThisWorkbook.Name & ";" & _ "Extended Properties=""Excel 12.0 Macro;HDR=YES"";" .Open End With ' Execute once and display... objRs.Open sSQL, objConn
Solved by C. D. in 29 mins