IsnUmeric with range

makis1023

New Member
Joined
Jun 16, 2021
Messages
49
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
Hello all,

I have the following code that works great. Because it will be big enough I want to choose only the numbers from E or J etc and not have to make choise (ie E34:E66. J15:J33)

VBA Code:
Sub BuildInvoiceAll()
  Dim ws As Variant, arr1 As String, arr2 As String, arr3 As String, arr4 As String, arry As Variant
  Dim i As Long, j As Long, nr As Long
  Dim cell As Range, f As Range
  Dim Descript As String
    
  Application.ScreenUpdating = False
  'Set array of worksheet names to copy from
  ws = Array("AUDIO", "LIGHTS", "HOISTS - TRUSS - DRAPES", "DISTRO - CABLES - MISC")
  
  'cells to AUDIO sheet
  arr1 = "E:E, J:J"
  'cells to LIGHTS sheet
  arr2 = "E13:E34, J13:J59, E36:E59, E73:E89, J73:J82, J84:J91, E91:E98, J93:J101, E100:E109, J103:J113"
  'cells to HOISTS sheet
  arr3 = "E13:E28, K13:K37, E30:E40, E42:E52, E67:E91, K67:K85, E106:E123, K106:K119, K121:K129, E127:E137"
  'cells to DISTRO sheet
  arr4 = "E13:E35, K13:K50, E37:E50, E64:E116, K64:K88, K92:K108, K111:K120, E131:E148, K131:K148, K150:K159," & _
         "E152:E180 , K163:K188 , K190:K203 , E184:E216 , K207:K238 , K240:K249 "
  arry = Array(arr1, arr2, arr3, arr4)
  nr = 14
  Sheets("PROFORMA DRYHIRE").Range("A15:C70").ClearContents
   For i = LBound(ws) To UBound(ws)                  'Loop through all shees in the array
    For Each cell In Sheets(ws(i)).Range(arry(i))   'Loop through all cells in the multirange
      If cell > 0 Then                               'See if anything entered in pieces
        Descript = cell.Offset(0, -3)               'get description from column B
        With Sheets("PROFORMA DRYHIRE")
          Set f = .Range("A15:A70").Find(Descript, , xlValues, xlWhole)
          If Not f Is Nothing Then
            nr = f.Row
          Else
            nr = nr + 1
            If nr > 70 Then
              MsgBox "Rows are full"
              Exit Sub
            End If
          End If
        
          .Cells(nr, "A") = Descript                'Populate values in PROFORMA sheet
          .Cells(nr, "B") = cell                    'get pieces from column E
          .Cells(nr, "C") = cell.Offset(0, -1)      'get price p/d from column D
        End With
      End If
    Next cell
  Next i
  Application.ScreenUpdating = False
End Sub

Can this be done?

Thank you!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
I have the following code that works great. Because it will be big enough I want to choose only the numbers from E or J etc and not have to make choise (ie E34:E66. J15:J33)
I have to be 100% honest with you here. I am not sure I understand your question.
Can you try explaining it in more detail, maybe walk us through an example?
 
Upvote 0
Thank you for your answer and effort.
What I am trying to do is not to enter all the ranges i.e. E2:E45, K3:K88 etc but instead to just enter K:K, E:E to check all the column.
And furthermore, into E column there is text, and because I only need numeric values to do mathematical equation, I need to choose only numeric.
I have managed to use IsNumeric but it is not working well and brings also text.
Here is the code

VBA Code:
For i = LBound(ws) To UBound(ws)                  'Loop through all shees in the array
    For Each cell In Sheets(ws(i)).Range(arry(i))   'Loop through all cells in the multirange
    If Not IsNumeric(cell) Then 
        all_numeric = False
        Exit For
    End If
Next cell

I hope you understand.
Thank you
 
Upvote 0
Can you show us some sample data and walk us through an actual example of what you are trying to do?
I think it will make a lot more sense to us if we could see what your data looks like, and get an understanding of exactly what you are trying to end up with.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
I have used xl2bb before but now I cant get it work with office365. I will be back with the example. Thank you
 
Upvote 0
Ok this is the example.

The following are the sheets with data I am trying to retrieve data


AUDIO Sheet

PROFORMA2.xlsm
BCDEFGHIJKL
1 SPEAKERS QTYPRICE PER DAYPCSAMPLIFIERSQTYPRICE PER DAYPCS
2CLAIR BROS C1216€110,00L-ACOUSTICS LA 4870€30,000
3CLAIR BROS C8 16€50,00L-ACOUSTICS LA 2417€20,000
4CLAIR BROS CS1184€50,00L-ACOUSTICS LA 177€15,000
5L-ACOUSTICS V-DOSC40€80,00L-ACOUSTICS LA 153€20,000
6L-ACOUSTICS dV-DOSC114€30,00L-ACOUSTICS LA 12X32€100,000
7L-ACOUSTICS KUDO6€60,00L-ACOUSTICS LA 4X8€60,000
8L-ACOUSTICS SYVA55€310,00LAB GRUPPEN PLM 12K4410€100,000
9L-ACOUSTICS ARCS WIDE16€40,00LAB GRUPPEN FP 1000010€25,000
10L-ACOUSTICS X1524€45,00LAB GRUPPEN FP C68:46€20,000
11L-ACOUSTICS X1224€35,00POWERSOFT K316€25,000
12L-ACOUSTICS X816€30,00POWERSOFR M50Q16€20,000
13L-ACOUSTICS FM11518€25,00YPSILON M100034€10,000
14L-ACOUSTICS XT-1158€25,00YPSILON M200092€15,000
15L-ACOUSTICS XT-128€20,00YPSILON S100018€15,000
16L-ACOUSTICS MTD 108A12€20,000
17L-ACOUSTICS KS 2824€80,000
18L-ACOUSTICS dV-SUB16€25,000
19L-ACOUSTICS SB1816€35,000
20EAW SB 100050€25,00PROCESSORSQTYPRICE PER DAYPCS
21NEXO PS1547€20,00DRIVERACK CLAIR -WLS-SMAART-LM441€100,000
22NEXO PS 1012€20,00XTA DP 4486€50,000
23ELECTROVOICE ELX112p18€20,00XTA DP 22616€25,0015375
24SLS LS 880072€20,00XTA DP 2248€20,0025500
25LLC 115FM14€5,0035175
26KLARK TEKNIK DN 80002€25,00451125
27NEXO TD PS 1531€5,000
28NEXO TD PS 105€5,000
290
300
310
320
33
34
AUDIO
Cell Formulas
RangeFormula
K2:K19,K21:K32K2=I2*J2



LIGHTS Sheet

PROFORMA2.xlsm
BCDEFGHIJKL
1MOVING LITESQTYPRICE PER DAYPCSGENERICSQTYPRICE PER DAYPCS
2ROBE BMFL WASH BEAM20€150,00ETC S4 ZOOM BODY 291€10,000
3CLAY PAKY MYTHOS -2 62€100,00ETC S4 LENS 15-30149€5,000
4CLAY PAKY SHARPY16€50,00ETC S4 LENS 25-50142€5,000
5CLAY PAKY HPE 1500 SPOT32€80,00ETC S4 BODY 96€10,000
6CLAY PAKY ALPHA PROFILE 150032€100,00ETC S4 3617€5,000
7CLAY PAKY ALPHA PROFILE 120012€60,00ETC S4 05 28€10,000
8CLAY PAKY ALPHA WASH 1200 (plus 16 off)100€50,00ETC S4 1051€10,000
9CLAY PAKY ALPHA WASH 5758€40,00ETC S4 JUNIOR 25-5032€15,000
10MARTIN MAC 2K PROFILE30€40,000
11MARTIN MAC 2K new GOBO36€50,000
12MARTIN MAC 2K PERFORMANCE28€50,0002 LITE20€8,000
13MARTIN MAC 2K WASH33€40,0004 LITE20€10,000
14FOS BEAM TITAN 40€35,0008 LITE26€15,000
15FOS BEAM 7R 83€25,000
16ETC REVOLUTION S44€50,00SHOWTEC SUNSTRIP24€20,000
17NOVALIGHT HIGH GROUND16€75,00ATOMIC 3K STROBES32€20,000
18NOVALIGHT FLOWER2€75,00LDR NOTA 1KW FRESNEL / PC60€10,000
19LDR NOTA 2KW FRESNEL / PC170€15,000
20LDR INNO 1KWC ASSYMETRIC100€10,000
21LDR RIMA 500W 22€5,000
22ELATION OPTI-PAR ETL-PARNEL 500W84€5,000
23ELECTROM HIQI 400W72€3,000
24LED FIXTURESQTYPRICE PER DAYPCS0
25ROBE SPIDER56€75,000
26ROBE LED BEAM 15032€35,00UV LIGHT 400W8€5,000
27GLP X4 BAR 2012€80,00QUARTZ VARIBEAM 100012€3,000
28ETC LED S4 LUSTR2 20€60,00ACL IN BARS OF FOUR128€10,000
29PORTMAN P-116€60,00PAR 64 IN BARS OF SIX420€20,000
30CHAUVET FREEDOM PAR HEX 440€12,50PAR 64200€5,000
31FOS WASH Q19 HP24€30,00PAR 64 FLOOR80€5,000
32FOS HELIX15€25,00PAR 5677€3,000
33FOS F596€25,000
34FOS LED BAR 18X10W PRO99€20,00PAR 36100€3,000
35FOS LED PAR BATTERY81€8,00PAR 1680€3,000
36FOS LED PAR 18X10W PRO IP6548€10,000
37FOS LED PAR UV12€10,00SYMMETRIC FLOOD LIGHT 200W150€3,000
38FOS PIXEL LED 7X7W WW24€15,00SYMMETRIC FLOOD LIGHT 1000W35€5,000
39AMERICAN DJ INNO COLOR BEAM38€20,000
40AMERICAN DJ PAR 64B LED PRO56€5,000
41AMERICAN DJ MATRIX LED BEAM11€20,000
42ELATION E LED TRI 64S59€5,000
43LEADER LIGHT PRO PIXEL 1238€15,000
44
45
46
47
48
LIGHTS
Cell Formulas
RangeFormula
K2:K43K2=I2*J2


and the sheet where I want to enter the retrieved data and has the code.

PROFORMA2.xlsm
ABCDE
1
2ΥΠΕΥΘΥΝΟΣ
3 ΠΡΟΣΦΟΡΑ / PRO-FORMA ΠΕΛΑΤΗΣ
4NO: ΥΠΟΨΙΝ
5ΔΙΕΥΘΥΝΣΗ
6ΠΟΛΗ
7ΑΦΜ
8ΔOY
9ΤΗΛ
10email
11ΠΑΡΑΓΩΓΗ
12ΠΕΡΙΟΔΟΣ
13
14ΤΥΠΟΣ - ΠΕΡΙΓΡΑΦΗΤΕΜΑΧΙΑΤΙΜΗ ΜΟΝΑΔΟΣΣΥΝΟΛΟ
150,00 €
160,00 €
170,00 €
180,00 €
190,00 €
200,00 €
210,00 €
220,00 €
230,00 €
240,00 €
250,00 €
260,00 €
270,00 €
280,00 €
290,00 €
300,00 €
310,00 €
320,00 €
330,00 €
340,00 €
350,00 €
360,00 €
370,00 €
380,00 €
390,00 €
400,00 €
410,00 €
420,00 €
430,00 €
440,00 €
450,00 €
460,00 €
470,00 €
480,00 €
490,00 €
500,00 €
510,00 €
520,00 €
530,00 €
540,00 €
550,00 €
560,00 €
570,00 €
580,00 €
590,00 €
600,00 €
610,00 €
620,00 €
630,00 €
640,00 €
650,00 €
660,00 €
670,00 €
680,00 €
690,00 €
700,00 €
71ΣΥΝΟΛΟ ΗΜΕΡΑΣ0,00 €
72ΤΡΟΠΟΣ ΠΛΗΡΩΜΗΣ ΧΡΕΩΣΕΙΣ
73ΣΥΝΟΛΟ0,00 €
74ΕΚΠΤΩΣΗ0,00 €
75ΦΠΑ0,00 €
76
77
PROFORMA DRYHIRE
Cell Formulas
RangeFormula
D15:D70D15=B15*C15
D71D71= SUM(D47:D70)
D73D73=D72*D71
D74D74=D73*0.8
D75D75=D74*0.24



And the VBA Code

VBA Code:
Sub BuildInvoiceAll()
  Dim ws As Variant, arr1 As String, arr2 As String, arr3 As String, arr4 As String, arry As Variant
  Dim i As Long, j As Long, nr As Long
  Dim cell As Range, f As Range
  Dim Descript As String
  Dim all_numeric As Boolean
  'all_numeric = True
    
  Application.ScreenUpdating = False
  'Set array of worksheet names to copy from
  ws = Array("AUDIO", "LIGHTS")
  
  'cells to AUDIO sheet
  arr1 = "E:E, J:J"
  'cells to LIGHTS sheet
  arr2 = "E:E, J:J"
  'cells to HOISTS sheet
  'arr3 = "E:E, K:K"
  'cells to DISTRO sheet
  'arr4 = "E:E, K:K"
  arry = Array(arr1, arr2)
  nr = 14
  Sheets("PROFORMA DRYHIRE").Range("A15:C70").ClearContents
  For i = LBound(ws) To UBound(ws)                  'Loop through all shees in the array
    For Each cell In Sheets(ws(i)).Range(arry(i))   'Loop through all cells in the multirange
    If Not IsNumeric(cell) Then 'I also want to get rid of empty cell
        all_numeric = False
        Exit For
    End If
Next cell
For Each cell In Sheets(ws(i)).Range(arry(i))
      If cell > 0 Then                              'See if anything entered in pieces
        Descript = cell.Offset(0, -3)               'get description from column B
        With Sheets("PROFORMA DRYHIRE")
          Set f = .Range("A15:A70").Find(Descript, , xlValues, xlWhole)
          If Not f Is Nothing Then
            nr = f.Row
          Else
            nr = nr + 1
            If nr > 70 Then
              MsgBox "Rows are full"
              Exit Sub
            End If
          End If
          .Cells(nr, "A") = Descript                'Populate values in PROFORMA sheet
          .Cells(nr, "B") = cell                    'get pieces from column E
          .Cells(nr, "C") = cell.Offset(0, -1)      'get price p/d from column D
        End With
      End If
    Next cell
  Next i
  Application.ScreenUpdating = False
End Sub
Thank you!
 
Upvote 0

Forum statistics

Threads
1,214,913
Messages
6,122,207
Members
449,074
Latest member
cancansova

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top